protected override void Initialize()
        {
            Current = GetNext();

            if (Current == null || Current.answers == null)
            {
                return;
            }

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            Answer.SetMultiOptionAnswer(Current.right, Current.answers[Current.right]);

            Container container = new Container(DrawAreaX, DrawAreaY + 0.2, 0.8, Current.answers.Length * 0.15);

            AddWidget(container);

            for (int i = 0; i < Current.answers.Length; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.8, 0.1);
                drawable_area.X = DrawAreaX;
                drawable_area.Y = DrawAreaY + 0.2 + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    e.Context.MoveTo(0.05, 0.02);
                    e.Context.ShowPangoText(String.Format(Translations.GetString("{0}) {1}"), Answer.GetMultiOption(n), Current.answers[n].ToString()));
                };
            }
            SetAnswerCorrectShow();
        }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        m_DrawableLine    = GetComponent <DrawableLine>();
        m_DrawableArea    = GetComponent <DrawableArea>();
        m_DrawableVolume  = GetComponent <DrawableVolume>();
        m_DrawableSphere  = GetComponent <DrawableSphere>();
        m_DrawablePolygon = GetComponent <DrawablePolygon>();

        // For introduction
        m_DrawableVolume.AddListener(() => { mIntroductionScript.CheckVolume(m_DrawableVolume.m_LastCreatedShape.transform, DrawableVolume.m_SubdivisionScale); },
                                     DrawableVolume.ListenerType.PostFinish);


        m_CurrentTool = Tool.None;
//        m_ToolText = GameObject.Find("ActiveToolText").GetComponent<Text>();

        mIntroductionScript = FindObjectOfType <IntroductionScript>();

        UpdateGridScale();
        GlobalGridScale.AddScaleListener(UpdateGridScale);

        m_Line   = m_Shape.transform.Find("Line").gameObject;
        m_Area   = m_Shape.transform.Find("Area").gameObject;
        m_Volume = m_Shape.transform.Find("Volume").gameObject;
        m_Mesh   = m_Shape.transform.Find("Mesh").gameObject;

        m_PointerController = m_Pointer.GetComponent <PointerController>();

        penInput           = FindObjectOfType <PenInputController>();
        initialPenPosition = penInput.transform.position;

        deleteTool = FindObjectOfType <DeleteToolOld>();
        initialDeleteToolPosition = deleteTool.transform.position;
    }
Ejemplo n.º 3
0
        private void SetDrawingAreas()
        {
            double       x = DrawAreaX, y = DrawAreaY;
            DrawableArea drawable_area;
            const double figure_size = 0.3, margin = 0.1;

            HorizontalContainer container = new HorizontalContainer(x, y, 0.8, 0.4);

            AddWidget(container);

            for (int i = 0; i < figures.GetAll().Length; i++)
            {
                if (i == 2)
                {
                    container = new HorizontalContainer(x, y + 0.4, 0.8, 0.4);
                    AddWidget(container);
                }

                drawable_area = new DrawableArea(figure_size + margin, 0.35);
                drawable_area.SelectedArea = new Rectangle(0, 0, figure_size, 0.35);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int    n      = (int)e.Data;
                    Figure figure = figures.GetAll()[n];
                    figure.Draw(e.Context, 0, 0, figure_size);
                    e.Context.DrawTextCentered(figure_size / 2, 0.32, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };

                container.AddChild(drawable_area);
            }
        }
Ejemplo n.º 4
0
        void DrawingAnswerObjects()
        {
            Container container = new Container(DrawAreaX + 0.2, DrawAreaY + 0.4, 0.5, answers.Length * 0.10);

            AddWidget(container);

            for (int i = 0; i < answers.Length; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.4, 0.1);
                drawable_area.X = DrawAreaX + 0.23;
                drawable_area.Y = DrawAreaY + 0.4 + i * 0.1;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int d = (int)e.Data;
                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.07, 0.02);
                    e.Context.ShowPangoText(String.Format(Translations.GetString("{0}) {1}"), Answer.GetMultiOption(d),
                                                          converter.ToString(answers[d])));
                };
            }
        }
Ejemplo n.º 5
0
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                div3         = true;
                max_primeidx = 55;                 // 263
                break;

            case GameDifficulty.Master:
                div3         = false;
                max_primeidx = total_primes;
                break;

            case GameDifficulty.Medium:
            default:
                div3         = true;
                max_primeidx = 95;                 // 503
                break;
            }

            numbers = new int [total_nums];

            for (int i = 0; i < numbers.Length; i++)
            {
                numbers [i] = GenerateNonPrime();
            }

            answer_idx           = random.Next(numbers.Length);
            answer               = primes [random.Next(max_primeidx + 1)];
            numbers [answer_idx] = answer;
            Answer.SetMultiOptionAnswer(answer_idx, answer.ToString());

            // Drawing objects
            double    x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
            Container container = new Container(x, y, 1 - (x * 2), 0.6);

            AddWidget(container);

            for (int i = 0; i < numbers.Length; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.3, 0.1);
                drawable_area.X = x;
                drawable_area.Y = y + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.02, 0.02);
                    e.Context.ShowPangoText(String.Format("{0}) {1:##0.###}", Answer.GetMultiOption(n), numbers [n]));
                };
            }
        }
Ejemplo n.º 6
0
        protected override void Initialize()
        {
            random_indices = new ArrayListIndicesRandom((int)Figures.Last);
            random_indices.Initialize();
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            for (int i = 0; i < (int)Figures.Last; i++)
            {
                if (random_indices[i] == (int)Figures.Third)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            HorizontalContainer container = new HorizontalContainer(DrawAreaX, DrawAreaY + figure_size + 0.16, 0.8, 0.3);

            DrawableArea drawable_area;

            AddWidget(container);

            for (int i = 0; i < (int)Figures.Last; i++)
            {
                drawable_area = new DrawableArea(space_figures, 0.2);
                drawable_area.SelectedArea = new Rectangle(0, 0, figure_size, figure_size);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    switch ((Figures)random_indices[n])
                    {
                    case Figures.First:
                        DrawDiamon(e.Context, 0, 0, CerclePosition.Right | CerclePosition.Left);
                        break;

                    case Figures.Second:
                        DrawDiamon(e.Context, 0, 0, CerclePosition.Top | CerclePosition.Right);
                        break;

                    case Figures.Third:
                        DrawDiamon(e.Context, 0, 0, CerclePosition.Bottom | CerclePosition.Top);
                        break;

                    default:
                        throw new InvalidOperationException();
                    }

                    e.Context.MoveTo(0.02, 0.25);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Ejemplo n.º 7
0
        protected override void Initialize()
        {
            sum_offset     = random.Next(3);
            random_indices = new ArrayListIndicesRandom(slices.Length / items_per_slice);
            random_indices.Initialize();
            ans_pos = random.Next(possible_answers);

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            Answer.SetMultiOptionAnswer(ans_pos, Answer.GetFigureName(ans_pos));

            bad_answers = new int [possible_answers * items_per_slice];
            for (int i = 0; i < bad_answers.Length; i++)
            {
                bad_answers[i] = 1 + random.Next(9);
            }

            HorizontalContainer container = new HorizontalContainer(DrawAreaX, 0.62, 0.8, 0.3);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < possible_answers; i++)
            {
                drawable_area = new DrawableArea(0.8 / 3, 0.3);
                drawable_area.SelectedArea = new Rectangle(0, 0, radius, 0.2);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawSlice(e.Context, 0, 0);
                    if (n == ans_pos)
                    {
                        int pos = random_indices [0];
                        DrawSliceText(e.Context, 0, 0, 0, (sum_offset +
                                                           slices [pos * items_per_slice]).ToString(),
                                      (sum_offset + slices [1 + (pos * items_per_slice)]).ToString(),
                                      (sum_offset + slices [2 + (pos * items_per_slice)]).ToString());
                    }
                    else
                    {
                        DrawSliceText(e.Context, 0, 0, 0,
                                      bad_answers [n * items_per_slice].ToString(),
                                      bad_answers [1 + (n * items_per_slice)].ToString(),
                                      bad_answers [2 + (n * items_per_slice)].ToString());
                    }

                    e.Context.MoveTo(0.0, 0.25);
                    e.Context.DrawTextCentered(radius / 2, 0.25, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Ejemplo n.º 8
0
        protected override void Initialize()
        {
            int answers;
            int correct_answer;

            if (predicates == null)
            {
                LoadPredicates();
            }

            question = random.Next(predicates.Length);

            correct_answer = predicates [question].answer_index;
            answers        = predicates [question].options.Length;
            random_indices = new ArrayListIndicesRandom(answers - 1);
            random_indices.Initialize();
            random_indices.Add(answers - 1);

            for (int i = 0; i < answers; i++)
            {
                if (random_indices[i] == correct_answer)
                {
                    Answer.Correct = Answer.GetMultiOption(i);
                    break;
                }
            }

            Container container = new Container(DrawAreaX, DrawAreaY + 0.15, 0.8, 0.6);

            AddWidget(container);

            for (int i = 0; i < predicates[question].options.Length; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.8, 0.12);
                drawable_area.X = DrawAreaX;
                drawable_area.Y = DrawAreaY + 0.15 + i * 0.18;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int data   = (int)e.Data;
                    int option = random_indices [data];

                    e.Context.SetPangoNormalFontSize();
                    e.Context.DrawStringWithWrapping(0.05, 0.02, String.Format(Translations.GetString("{0}) {1}"), Answer.GetMultiOption(data),
                                                                               predicates[question].options[option].ToString()), 0.8 - DrawAreaX);
                    e.Context.Stroke();
                };
            }
        }
        protected override void Initialize()
        {
            Current = GetNext();

            if (Current == null || Current.answers == null)
            {
                return;
            }

            string [] items;

            items = Current.question.Split(AnalogiesFactory.Separator);

            if (items.Length == 2)
            {
                sample = items [1].Trim();
            }
            else
            {
                sample = string.Empty;
            }

            samples = items [0].Trim();

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            Answer.Correct          = Answer.GetMultiOption(Current.right);

            Container container = new Container(DrawAreaX, DrawAreaY + 0.25, 0.8, Current.answers.Length * 0.15);

            AddWidget(container);

            for (int i = 0; i < Current.answers.Length; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.8, 0.1);
                drawable_area.X = DrawAreaX;
                drawable_area.Y = DrawAreaY + 0.25 + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    e.Context.MoveTo(0.05, 0.02);
                    e.Context.ShowPangoText(String.Format(Translations.GetString("{0}) {1}"), Answer.GetMultiOption(n), Current.answers[n].ToString()));
                };
            }
            SetAnswerCorrectShow();
        }
Ejemplo n.º 10
0
        private void SetDrawingAreas()
        {
            double rect_w = DrawAreaWidth / rows;
            double rect_h = DrawAreaHeight / columns;

            Container container = new Container(DrawAreaX, DrawAreaY, 0.8, 0.8);

            AddWidget(container);

            for (int column = 0; column < columns; column++)
            {
                for (int row = 0; row < rows; row++)
                {
                    bool         cercled;
                    DrawableArea drawable_area = new DrawableArea(rect_w, rect_h);
                    drawable_area.X = DrawAreaX + row * rect_w;
                    drawable_area.Y = DrawAreaY + column * rect_h;
                    container.AddChild(drawable_area);

                    cercled = numbers[column + (row * 4)] % divisor == 0 && good_pos != column + (row * 4);
                    Number number = new Number {
                        NumberString = numbers[column + (row * 4)].ToString(), Cercled = cercled
                    };
                    drawable_area.Data   = number;
                    drawable_area.DataEx = number.NumberString;

                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        Number num = (Number)e.Data;

                        e.Context.SetSourceColor(DefaultDrawingColor);
                        e.Context.Rectangle(0, 0, e.Width, e.Height);
                        e.Context.Stroke();

                        e.Context.DrawTextCentered(e.Width / 2, e.Height / 2, num.NumberString);

                        if (num.Cercled)
                        {
                            e.Context.Arc(e.Width / 2, e.Height / 2, 0.05, 0, 2 * Math.PI);
                            e.Context.FillGradient(e.Width / 2, e.Height / 2, 0.05, 0.05);
                        }

                        e.Context.Stroke();
                    };
                }
            }
        }
Ejemplo n.º 11
0
        private void SetDrawAnswer()
        {
            double h = 0.25, sel_marginw = 0.05, sel_marginh = 0.025;
            double x = DrawAreaX + 0.1, y = DrawAreaY + 0.62;
            int    fig_count = (int)Figures.Last;

            HorizontalContainer container = new HorizontalContainer(x, y, fig_count * (figure_size + space_x), h);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < fig_count; i++)
            {
                drawable_area = new DrawableArea(figure_size + space_x, h);
                drawable_area.SelectedArea = new Rectangle(-sel_marginw, -sel_marginh, figure_size + sel_marginw * 2, h);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int fig = (int)e.Data;

                    switch ((Figures)random_indices[fig])
                    {
                    case Figures.TwoLines:
                        DrawTwoLines(e.Context, 0, 0, figure_size);
                        break;

                    case Figures.Cross:
                        DrawCross(e.Context, 0, 0, figure_size);
                        break;

                    case Figures.RotatedCross:
                        DrawRotatedCross(e.Context, 0, 0, figure_size);
                        break;
                    }

                    e.Context.MoveTo(0, 0.17);
                    e.Context.ShowPangoText(Answer.GetFigureName(fig));
                };
            }
        }
Ejemplo n.º 12
0
        protected override void Initialize()
        {
            question_indices = new ArrayListIndicesRandom(question_columns);
            question_indices.Initialize();

            answer_indices = new ArrayListIndicesRandom(possible_answers);
            answer_indices.Initialize();

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            BuildPossibleAnswers();

            const double        total_width = 0.8, total_height = 0.42;
            HorizontalContainer container = new HorizontalContainer(DrawAreaX, 0.52, total_width, total_height);

            AddWidget(container);

            // Possible answers columns
            for (int ans = 0; ans < possible_answers; ans++)
            {
                DrawableArea drawable_area = new DrawableArea(total_width / possible_answers, total_height);
                drawable_area.Data   = ans;
                drawable_area.DataEx = Answer.GetMultiOption(ans);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    double width = total_width / possible_answers;
                    double x = (width - figure_size) / 2, y = 0;
                    int    column = (int)e.Data;

                    for (int figure = 0; figure < figures_column; figure++)
                    {
                        DrawFigure(e.Context, x, y, figure_answers [(column * figures_column) + figure]);
                        y += figure_size + space_height;
                    }

                    e.Context.DrawTextCentered(width / 2, total_height - 0.02, Answer.GetFigureName(column));
                    e.Context.Stroke();
                };
            }
            Answer.SetMultiOptionAnswer(answer_indices[good_answer], Answer.GetFigureName(answer_indices[good_answer]));
        }
Ejemplo n.º 13
0
        protected override void Initialize()
        {
            Answer.CheckAttributes  |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            random_indices_questions = new ArrayListIndicesRandom(4);
            random_indices_questions.Initialize();

            random_indices_answers = new ArrayListIndicesRandom(3);
            random_indices_answers.Initialize();

            for (int i = 0; i < random_indices_answers.Count; i++)
            {
                if (random_indices_answers [i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            HorizontalContainer container = new HorizontalContainer(0.1, 0.5, 0.8, 0.4);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < 3; i++)
            {
                drawable_area        = new DrawableArea(0.8 / 3, 0.4);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawAnswerFigures(e.Context, 0.05, 0.2, random_indices_answers [n]);
                    e.Context.MoveTo(0.05, 0.33);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                };
            }
        }
Ejemplo n.º 14
0
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            possible_answers        = new ArrayListIndicesRandom(3);
            possible_answers.Initialize();

            puzzle_index = random.Next(puzzles.Length);
            puzzle       = puzzles [puzzle_index];

            DrawableArea        drawable_area;
            HorizontalContainer container = new HorizontalContainer(0.05, 0.5, 0.9, figure_size + 0.1);

            AddWidget(container);

            for (int i = 0; i < possible_answers.Count; i++)
            {
                drawable_area              = new DrawableArea(figure_size + space_figures, figure_size + 0.1);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                drawable_area.SelectedArea = new Rectangle(space_figures / 2, space_figures / 2, figure_size, figure_size);

                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    DrawPossibleAnswer(e.Context, space_figures / 2, space_figures / 2, possible_answers [(int)e.Data]);
                    e.Context.DrawTextCentered(space_figures / 2 + figure_size / 2, space_figures + figure_size + 0.02,
                                               Answer.GetFigureName((int)e.Data));
                };
            }

            for (int i = 0; i < possible_answers.Count; i++)
            {
                if (possible_answers[i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }
        }
Ejemplo n.º 15
0
        private void SetDrawingAreas()
        {
            double       x = DrawAreaX, y = DrawAreaY + 0.05;
            DrawableArea drawable_area;

            HorizontalContainer container = new HorizontalContainer(x, y, 0.8, 0.3);

            AddWidget(container);

            for (int i = 0; i < arcs_indices.Count; i++)
            {
                if (i == 2)
                {
                    container = new HorizontalContainer(x, y + 0.4, 0.8, 0.3);
                    AddWidget(container);
                }

                drawable_area        = new DrawableArea(0.3 + 0.1, 0.3);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n   = (int)e.Data;
                    Arc arc = arcs[arcs_indices[n]];

                    e.Context.Arc(arc.X, arc.Y, arc.Size, ToRadians(arc.StartAngle), ToRadians(arc.EndAngle));
                    e.Context.Stroke();

                    e.Context.DrawTextCentered(0.2, 0.28,
                                               String.Format(Translations.GetString("Arc {0}"), Answer.GetMultiOption(n)));

                    e.Context.Stroke();
                };

                container.AddChild(drawable_area);
            }
        }
Ejemplo n.º 16
0
        private void SetDrawingAreas()
        {
            double rect_w = DrawAreaWidth / columns;
            double rect_h = DrawAreaHeight / rows;

            Container container = new Container(DrawAreaX, DrawAreaY, 0.8, 0.8);

            AddWidget(container);

            for (int column = 0; column < columns; column++)
            {
                for (int row = 0; row < rows; row++)
                {
                    DrawableArea drawable_area = new DrawableArea(rect_w, rect_h);
                    drawable_area.X = DrawAreaX + column * rect_w;
                    drawable_area.Y = DrawAreaY + row * rect_h;
                    container.AddChild(drawable_area);

                    string num = grid[row * columns + column].ToString();
                    drawable_area.Data   = num;
                    drawable_area.DataEx = num;

                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        string number = (string)e.Data;

                        e.Context.Rectangle(0, 0, e.Width, e.Height);
                        e.Context.Stroke();

                        e.Context.SetPangoLargeFontSize();
                        e.Context.DrawTextCentered(e.Width / 2, e.Height / 2, number);
                        e.Context.Stroke();
                    };
                }
            }
        }
Ejemplo n.º 17
0
        protected override void Initialize()
        {
            double pos_x = 0, sel_width;

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            gametype = (GameType)random.Next((int)GameType.Last + 1);

            switch (gametype)
            {
            case GameType.Equations:
                pos_x     = 0.1;
                sel_width = 0.5;
                equations = equations_a;
                break;

            case GameType.Numbers:
            {
                int    num, evens;
                int [] seeds = { 25, 26, 28, 30, 18, 21, 22 };
                ArrayListIndicesRandom random_seeds = new ArrayListIndicesRandom(seeds.Length);

                pos_x     = 0.2;
                sel_width = 0.32;
                // Make sure that one of the numbers only is not even or odd to avoid
                // this rationale as valid answer too
                do
                {
                    evens = 0;
                    random_seeds.Initialize();

                    equations = new string [max_equations];
                    for (int i = 0; i < max_equations - 1; i++)
                    {
                        num           = seeds [random_seeds [i]];
                        equations [i] = num.ToString() + (num * num).ToString();
                        if (num % 2 == 0)
                        {
                            evens++;
                        }
                    }
                    num = seeds [random_seeds [max_equations - 1]];
                    equations [max_equations - 1] = num.ToString() + ((num * num) - 20).ToString();

                    if (num % 2 == 0)
                    {
                        evens++;
                    }
                } while (evens <= 1 || max_equations - evens <= 1 /* odds */);
                break;
            }

            default:
                throw new InvalidOperationException();
            }

            random_indices = new ArrayListIndicesRandom(equations.Length);
            random_indices.Initialize();

            for (int i = 0; i < random_indices.Count; i++)
            {
                if (random_indices[i] == wrong_answer)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            Container container = new Container(DrawAreaX + pos_x, DrawAreaY + 0.2, 0.5, random_indices.Count * 0.1);

            AddWidget(container);

            for (int i = 0; i < random_indices.Count; i++)
            {
                DrawableArea drawable_area = new DrawableArea(sel_width, 0.1);
                drawable_area.X = DrawAreaX + pos_x;
                drawable_area.Y = DrawAreaY + 0.2 + i * 0.1;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.05, 0.02);
                    // Translators: this "option) answer" for example "a) "21 x 60 = 1260". This should not be changed for most of the languages
                    e.Context.ShowPangoText(String.Format(Translations.GetString("{0}) {1}"), Answer.GetMultiOption(n), equations [random_indices[n]]));
                };
            }
        }
Ejemplo n.º 18
0
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            palette = new ColorPalette();

            switch (random.Next(2))
            {
            case 0:
                quest1  = g1question_A;
                quest2  = g1question_B;
                answer  = g1answer;
                ranswer = g1rightanswer;
                break;

            case 1:
                quest1  = g2question_A;
                quest2  = g2question_B;
                answer  = g2answer;
                ranswer = g2rightanswer;
                break;
            }

            random_indices = new ArrayListIndicesRandom(answers);
            random_indices.Initialize();

            for (int i = 0; i < answers; i++)
            {
                if (random_indices[i] == ranswer)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            double x = DrawAreaX, y = DrawAreaY;

            // Question
            DrawableArea        drawable_area;
            HorizontalContainer container = new HorizontalContainer(x, y, 0.8, 0.3);

            AddWidget(container);

            drawable_area           = new DrawableArea(container.Width / 2, 0.25);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                DrawSquare(e.Context, 0.15, 0);
            };

            drawable_area           = new DrawableArea(container.Width / 2, 0.25);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                DrawLShape(e.Context, 0.15, 0);
            };

            // Answers
            y        += 0.28;
            container = new HorizontalContainer(x, y, 0.8, 0.3);
            AddWidget(container);

            for (int i = 0; i < 2; i++)
            {
                drawable_area        = new DrawableArea(container.Width / 2, 0.25);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;
                    DrawPossibleAnswer(e.Context, 0.12, 0.03, answer, random_indices [n], n);

                    e.Context.DrawTextCentered(drawable_area.Width / 2, 0.22, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }

            container = new HorizontalContainer(x, y + 0.3, 0.8, 0.3);
            AddWidget(container);

            for (int i = 2; i < 4; i++)
            {
                drawable_area        = new DrawableArea(container.Width / 2, 0.25);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;
                    DrawPossibleAnswer(e.Context, 0.12, 0.03, answer, random_indices [n], n);

                    e.Context.DrawTextCentered(drawable_area.Width / 2, 0.22, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Ejemplo n.º 19
0
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                columns = rows = 5;
                break;

            case GameDifficulty.Medium:
                columns = rows = 6;
                break;

            case GameDifficulty.Master:
                columns = rows = 7;
                break;
            }

            squares         = columns * rows;
            rect_w          = 0.3 / rows;
            rect_h          = 0.3 / columns;
            squares_colours = new SquareColor [squares * answers];
            color_sheme     = random.Next(2);
            palette         = new ColorPalette(Translations);

            for (int i = 0; i < squares; i++)
            {
                squares_colours[i] = (SquareColor)random.Next((int)SquareColor.Length);
            }

            Randomize(squares_colours, 0, squares);
            Randomize(squares_colours, 0, squares * 2);
            Randomize(squares_colours, 0, squares * 3);

            answers_order = new ArrayListIndicesRandom(answers);
            answers_order.Initialize();

            for (int i = 0; i < answers_order.Count; i++)
            {
                if (answers_order[i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            base.Initialize();

            HorizontalContainer container = new HorizontalContainer(DrawAreaX, DrawAreaY, 0.8, 0.4);

            AddWidget(container);

            for (int i = 0; i < answers_order.Count; i++)
            {
                if (i == 2)
                {
                    container = new HorizontalContainer(DrawAreaX, DrawAreaY + 0.45, 0.8, 0.4);
                    AddWidget(container);
                }

                DrawableArea drawable_area = new DrawableArea(0.4, 0.4);
                container.AddChild(drawable_area);
                drawable_area.SelectedArea = new Rectangle(0.05, 0, 0.3, 0.3);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    palette.Alpha = alpha;
                    DrawSquare(e.Context, 0.05, 0, squares_colours, squares * answers_order[n]);
                    e.Context.MoveTo(0.05, 0 + block_space - 0.02);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Ejemplo n.º 20
0
        protected override void Initialize()
        {
            indications = new Indication [CurrentDifficulty == GameDifficulty.Easy ? 5 : 7];
            Indication.TurnDirection second_turn = (Indication.TurnDirection) 2 + random.Next(2);

            indications[0] = new Indication(Translations, Indication.Type.Start, 0);
            indications[1] = new Indication(Translations, Indication.Type.Turn, random.Next(2));           // right or left
            indications[2] = new Indication(Translations, Indication.Type.Turn, second_turn);              // up or down
            indications[3] = new Indication(Translations, Indication.Type.Turn, random.Next(2));           // right or left

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            if (CurrentDifficulty == GameDifficulty.Easy)
            {
                indications[4] = new Indication(Translations, Indication.Type.End, 1);
            }
            else
            {
                if (second_turn == Indication.TurnDirection.Up)
                {
                    indications[4] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Up);
                }
                else
                {
                    indications[4] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Down);
                }

                indications[5] = new Indication(Translations, Indication.Type.Turn, random.Next(2));                   // right or left
                indications[6] = new Indication(Translations, Indication.Type.End, 1);
            }

            indications_wrongA = CopyAnswer();
            indications_wrongB = CopyAnswer();
            indications_wrongC = CopyAnswer();

            if ((Indication.TurnDirection)indications[3].obj == Indication.TurnDirection.Right)
            {
                indications_wrongA[3] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Left);
            }
            else
            {
                indications_wrongA[3] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Right);
            }

            if (CurrentDifficulty == GameDifficulty.Easy)
            {
                if ((Indication.TurnDirection)indications[2].obj == Indication.TurnDirection.Up)
                {
                    indications_wrongB[2] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Down);
                }
                else
                {
                    indications_wrongB[2] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Up);
                }
            }
            else
            {
                if ((Indication.TurnDirection)indications[5].obj == Indication.TurnDirection.Right)
                {
                    indications_wrongB[5] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Left);
                }
                else
                {
                    indications_wrongB[5] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Right);
                }
            }

            if ((Indication.TurnDirection)indications[1].obj == Indication.TurnDirection.Right)
            {
                indications_wrongC[1] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Left);
            }
            else
            {
                indications_wrongC[1] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Right);
            }

            base.Initialize();

            answers = new ArrayListIndicesRandom(4);
            answers.Initialize();

            for (int i = 0; i < answers.Count; i++)
            {
                if (answers [i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    ans = i;
                    break;
                }
            }

            // Draw row 1
            HorizontalContainer container = new HorizontalContainer(0.05, 0.1, 0.9, 0.4);

            AddWidget(container);

            for (int i = 0; i < 2; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.45, 0.4);
                container.AddChild(drawable_area);
                drawable_area.SelectedArea      = new Rectangle(0, 0, 0.45, 0.3);
                drawable_area.Data              = i;
                drawable_area.DataEx            = Answer.GetMultiOption(i);
                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawPossibleAnswers(e.Context, 0.2, 0.1, WhichAnswer(answers[n]));
                    e.Context.MoveTo(0.2, 0.12 + 0.2);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                };
            }

            // Draw row 2
            container = new HorizontalContainer(0.05, 0.5, 0.9, 0.4);
            AddWidget(container);

            for (int i = 2; i < 4; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.45, 0.4);
                container.AddChild(drawable_area);
                drawable_area.SelectedArea      = new Rectangle(0, 0, 0.45, 0.3);
                drawable_area.Data              = i;
                drawable_area.DataEx            = Answer.GetMultiOption(i);
                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawPossibleAnswers(e.Context, 0.2, 0.1, WhichAnswer(answers[n]));
                    e.Context.MoveTo(0.2, 0.12 + 0.2);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                };
            }
        }
Ejemplo n.º 21
0
        protected override void Initialize()
        {
            random_indices = new ArrayListIndicesRandom(figures);
            random_indices.Initialize();

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            for (int i = 0; i < random_indices.Count; i++)
            {
                if (random_indices[i] != answer_index)
                {
                    continue;
                }

                Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                break;
            }

            const double        text_offset = 0.04;
            double              x = DrawAreaX, y = DrawAreaY + 0.1, box_size = (1 - (DrawAreaX * 2)) / 3;
            HorizontalContainer container1, container2, container = null;
            DrawableArea        drawable_area;

            for (int figure = 0; figure < figures; figure++)
            {
                switch (figure)
                {
                case 0:
                    x          = DrawAreaX;
                    container1 = new HorizontalContainer(x, y, 0.8, figure_size);
                    container  = container1;
                    AddWidget(container);
                    break;

                case 3:
                    x          = DrawAreaX;
                    y         += 0.4;
                    container2 = new HorizontalContainer(x, y, 0.8, figure_size);
                    container  = container2;
                    AddWidget(container);
                    break;

                default:
                    break;
                }

                drawable_area = new DrawableArea(box_size, figure_size);
                drawable_area.SelectedArea = new Rectangle((box_size - figure_size) / 2, 0, figure_size, figure_size);
                drawable_area.Data         = figure;
                drawable_area.DataEx       = Answer.GetMultiOption(figure);

                switch (random_indices[figure])
                {
                case 0:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawTriangle(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case 1:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawDiamon(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case 2:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawRectangleWithTriangles(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case 3:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawThreeTriangles(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case answer_index:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawRectangleWithCross(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;
                }

                container.AddChild(drawable_area);
                x += box_size;
            }
        }
Ejemplo n.º 22
0
        protected override void Initialize()
        {
            bool found;
            int  n, m;

            int [] mult = new int [3];

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                max_num       = 999;
                num_answ_ques = 3;
                break;

            case GameDifficulty.Medium:
                max_num       = 999;
                num_answ_ques = 4;
                break;

            case GameDifficulty.Master:
                max_num       = 9999;
                num_answ_ques = 4;
                break;
            }

            numbers = new int [num_answ_ques];
            answers = new int [num_answ_ques];

            // Common multipliers for all numbers
            for (m = 0; m < mult.Length; m++)
            {
                mult[m] = GetMultiplier(mult);
            }

            n = 0;
            while (n < numbers.Length)
            {
                numbers [n] = 4 + random.Next(5);
                for (int i = 1; i < 5; i++)
                {
                    numbers [n] = numbers [n] * (1 + random.Next(10));
                }

                for (m = 0; m < mult.Length; m++)
                {
                    numbers[n] = numbers [n] * mult[m];
                }

                if (numbers[n] > max_num || numbers[n] < 50)
                {
                    continue;
                }

                found = false;
                for (int i = 0; i < n; i++)
                {
                    if (numbers[i] == numbers [n])
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    n++;
                }
            }

            int answer = 0;

            // Avoid generating a set of answers in which none matches the condition
            while (answer == 0)
            {
                // Build a list of answers
                for (n = 0; n < answers.Length; n++)
                {
                    answers[n] = GetUniqueAnswer(mult, answers);
                }

                n = 0;
                for (int a = 0; a < answers.Length; a++)
                {
                    for (n = 0; n < answers.Length; n++)
                    {
                        if ((double)numbers[n] / (double)answers[a] != Math.Abs(numbers[n] / answers[a]))
                        {
                            break;
                        }
                    }

                    if (n == answers.Length && answers[a] > answer)
                    {
                        answer     = answers[a];
                        answer_idx = a;
                    }
                }
            }

            Answer.SetMultiOptionAnswer(answer_idx, answer.ToString());

            // Drawing objects
            Container container = new Container(DrawAreaX + 0.2, DrawAreaY + 0.25, 0.4, answers.Length * 0.15);

            AddWidget(container);

            for (int i = 0; i < answers.Length; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.3, 0.1);
                drawable_area.X = DrawAreaX + 0.23;
                drawable_area.Y = DrawAreaY + 0.27 + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int d = (int)e.Data;
                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.07, 0.02);
                    e.Context.ShowPangoText(String.Format(Translations.GetString("{0}) {1}"), Answer.GetMultiOption(d),
                                                          answers[d].ToString()));
                };
            }
        }
Ejemplo n.º 23
0
        protected override void Initialize()
        {
            int position;

            // In all these cases the clock logic clearly do not work since the small hand is in the next hour
            switch (random.Next(3))
            {
            case 0:
                position = 48;
                addition = 5;
                break;

            case 1:
                position = 38;
                addition = 15;
                break;

            case 2:
            default:
                position = 24;
                addition = 5;
                break;
            }

            handles = new int [clocks * handle_num];

            for (int i = 0; i < handles.Length; i++, i++)
            {
                handles [i]     = position / 10;
                handles [i + 1] = position - ((position / 10) * 10);
                position       += addition;
            }

            Answer.Correct = handles[7].ToString();

            // First row
            HorizontalContainer container = new HorizontalContainer(DrawAreaX, 0.05, 0.8, 0.45);
            DrawableArea        drawable_area;

            AddWidget(container);

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[0], handles[1]);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(0));
                e.Context.Stroke();
            };

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[2], handles[3]);
                e.Context.MoveTo(0.03, 0.29);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(1));
                e.Context.Stroke();
            };

            // Second row
            container = new HorizontalContainer(DrawAreaX, 0.05 + 0.45, 0.8, 0.45);
            AddWidget(container);

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[4], handles[5]);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(2));
                e.Context.Stroke();
            };

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[6], Answer.Draw == true ? handles[7] : 0);
                e.Context.MoveTo(0.03, 0.29);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(3));
                e.Context.Stroke();
            };

            /*DateTime dt1 = new DateTime (2008, 2, 20, handles[0], handles[1] * 5, 0);
             * DateTime dt2 = new DateTime (2008, 2, 20, handles[2], handles[3] * 5, 0);
             * Console.WriteLine ("t1 {0}", dt1);
             * Console.WriteLine ("t2 {0}", dt2);
             * Console.WriteLine ("Time diff {0} from 1st to 2nd", dt2-dt1);
             *
             * dt1 = new DateTime (2008, 2, 20, handles[2], handles[3] * 5, 0);
             * dt2 = new DateTime (2008, 2, 20, handles[4], handles[5] * 5, 0);
             * Console.WriteLine ("t1 {0}", dt1);
             * Console.WriteLine ("t2 {0}", dt2);
             * Console.WriteLine ("Time diff {0} from 1st to 2nd", dt2-dt1);
             *
             * dt1 = new DateTime (2008, 2, 20, handles[4], handles[5] * 5, 0);
             * dt2 = new DateTime (2008, 2, 20, handles[6], handles[7] * 5, 0);
             * Console.WriteLine ("t1 {0}", dt1);
             * Console.WriteLine ("t2 {0}", dt2);
             * Console.WriteLine ("Time diff {0} from 1st to 2nd", dt2-dt1);*/
        }
Ejemplo n.º 24
0
        protected override void Initialize()
        {
            int options_next, random_max, which = 0;

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                random_max = 30;
                break;

            default:
            case GameDifficulty.Medium:
                random_max = 50;
                break;

            case GameDifficulty.Master:
                random_max = 80;
                break;
            }

            do
            {
                // Fraction
                num        = 10 + random.Next(random_max);
                den        = 2 + random.Next(random_max / 5);
                percentage = 10 + random.Next(random_max);
                correct    = percentage / 100d * num / den;
            } while (correct < 1);

            options = new double [options_cnt];

            options_next             = 0;
            options [options_next++] = correct;
            options [options_next++] = percentage / 70d * num / den;
            options [options_next++] = percentage / 120d * num / den;
            options [options_next]   = percentage / 150d * num / den;

            random_indices = new ArrayListIndicesRandom(options_cnt);
            random_indices.Initialize();

            for (int i = 0; i < options_cnt; i++)
            {
                if (random_indices [i] == correct_pos)
                {
                    which = i;
                    break;
                }
            }

            Answer.SetMultiOptionAnswer(which, String.Format("{0:##0.##}", options[which]));

            // Options
            double    x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
            Container container = new Container(x, y, 1 - (x * 2), 0.6);

            AddWidget(container);

            for (int i = 0; i < options_cnt; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.3, 0.1);
                drawable_area.X = x;
                drawable_area.Y = y + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n    = (int)e.Data;
                    int indx = random_indices[n];

                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.02, 0.02);
                    e.Context.ShowPangoText(String.Format("{0}) {1:##0.##}", Answer.GetMultiOption(n), options [indx]));
                };
            }
        }
Ejemplo n.º 25
0
        public void CreateDrawingObjects(DrawingObject [] drawing_objects)
        {
            OptionDrawingObject option;
            double x = 0, y = 0, width = 0, height = 0;
            bool   first = true;
            int    randomized_options = 0;

            if (drawing_objects == null)
            {
                return;
            }

            // Calculate the size of container from the options and count the number of random options
            foreach (DrawingObject draw_object in drawing_objects)
            {
                option = draw_object as OptionDrawingObject;

                if (option == null)
                {
                    continue;
                }

                if (option.RandomizedOrder)
                {
                    randomized_options++;
                }

                if (first == true)
                {
                    x      = option.X;
                    y      = option.Y;
                    width  = option.Width;
                    height = option.Height;
                    first  = false;
                    continue;
                }

                if (option.X < x)
                {
                    x = option.X;
                }

                if (option.Y < y)
                {
                    y = option.Y;
                }

                if (option.X + option.Width > width)
                {
                    width = option.X + option.Width;
                }

                if (option.Y + option.Height > height)
                {
                    height = option.Y + option.Height;
                }
            }

            if (first == true)
            {
                return;
            }

            RandomizeOptions(drawing_objects, randomized_options);

            Container container = new Container(x, y, width - x, height - y);

            game_xml.AddWidget(container);

            if (Options == null)
            {
                Options = new List <OptionDrawingObject> ();
            }

            // Create drawing widgets objects
            int idx = 0;

            foreach (DrawingObject draw_object in drawing_objects)
            {
                option = draw_object as OptionDrawingObject;

                if (option == null)
                {
                    continue;
                }

                DrawableArea drawable_area = new DrawableArea(option.Width, option.Height);
                drawable_area.X = option.X;
                drawable_area.Y = option.Y;                 // + i * 0.15;
                container.AddChild(drawable_area);

                drawable_area.Data   = idx;
                drawable_area.DataEx = game_xml.Answer.GetMultiOption(idx);
                Options.Add(option);

                idx++;
                drawable_area.DrawEventHandler += DrawOption;
            }
        }
Ejemplo n.º 26
0
        protected override void Initialize()
        {
            bool duplicated;
            int  nums, options_next, dist, num_size, which = 0;

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                nums     = 3;
                dist     = nums * 3;
                num_size = 50;
                break;

            default:
            case GameDifficulty.Medium:
                nums     = 5;
                dist     = nums * 3;
                num_size = 150;
                break;

            case GameDifficulty.Master:
                nums     = 7;
                dist     = nums * 3;
                num_size = 500;
                break;
            }

            numbers = new double [nums];
            options = new double [options_cnt];

            do
            {
                // Random set of numbers
                correct = 0;
                for (int i = 0; i < nums; i++)
                {
                    numbers [i] = 10 + random.Next(num_size) + dist;
                    correct    += numbers [i];
                }

                correct = correct / nums;
            } while (correct != Math.Truncate(correct));

            options [correct_pos] = correct;
            options_next          = correct_pos + 1;

            // Generate possible answers
            while (options_next < options_cnt)
            {
                double ans;

                ans        = correct + random.Next(-dist, dist + 1);
                duplicated = false;

                // No repeated answers
                for (int num = 0; num < options_next; num++)
                {
                    // Due to decimal precision
                    if (options [num] == ans || options [num] == ans + 1 || options [num] == ans - 1)
                    {
                        duplicated = true;
                        break;
                    }
                }

                if (duplicated)
                {
                    continue;
                }

                options [options_next] = ans;
                options_next++;
            }

            random_indices = new ArrayListIndicesRandom(options_cnt);
            random_indices.Initialize();

            for (int i = 0; i < options_cnt; i++)
            {
                if (random_indices [i] == correct_pos)
                {
                    which = i;
                    break;
                }
            }

            Answer.SetMultiOptionAnswer(which, options [correct_pos].ToString());

            // Options
            double    x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
            Container container = new Container(x, y, 1 - (x * 2), 0.6);

            AddWidget(container);

            for (int i = 0; i < options_cnt; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.3, 0.1);
                drawable_area.X = x;
                drawable_area.Y = y + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n    = (int)e.Data;
                    int indx = random_indices[n];

                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.02, 0.02);
                    e.Context.ShowPangoText(String.Format("{0}) {1}", Answer.GetMultiOption(n), options [indx]));
                };
            }
        }
Ejemplo n.º 27
0
        protected override void Initialize()
        {
            ArrayListIndicesRandom random_indices = new ArrayListIndicesRandom(total_slices);
            Color clr;

            cp = new ColorPalette(Translations);

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            cercle_colors    = new Color [total_slices];
            badcercle_colors = new Color [total_slices];
            for (int i = 0; i < total_slices; i++)
            {
                cercle_colors [i]    = cp.Cairo(i);
                badcercle_colors [i] = cp.Cairo(i);
            }

            // Correct answer
            random_indices.Initialize();
            clr = badcercle_colors [random_indices[0]];
            badcercle_colors [random_indices[0]] = badcercle_colors [random_indices[1]];
            badcercle_colors [random_indices[1]] = clr;

            // Create random color order for the session
            start_indices = new int [circles];
            for (int i = 0; i < circles; i++)
            {
                start_indices[i] = (random_indices[i]);
            }

            ans_pos = random.Next(circles);
            Answer.SetMultiOptionAnswer(ans_pos, Answer.GetFigureName(ans_pos));

            const double        text_offset = 0.04;
            const double        witdh_used  = 0.9;     // Total width used for drawing all the figures
            const double        margin      = 0.1 / circles / 2;
            const double        box_size    = witdh_used / circles;
            double              y;
            HorizontalContainer container;
            DrawableArea        drawable_area;

            Color [] colors;

            y = DrawAreaY + 0.1 + (radius / 2);

            container = new HorizontalContainer(0.05, y, witdh_used, box_size);
            AddWidget(container);

            circle_parameters = new CircleParameters [circles];
            for (int i = 0; i < circles; i++)
            {
                if (ans_pos == i)
                {
                    colors = badcercle_colors;
                }
                else
                {
                    colors = cercle_colors;
                }

                circle_parameters [i]      = new CircleParameters(colors);
                drawable_area              = new DrawableArea(box_size, box_size);
                drawable_area.SelectedArea = new Rectangle((box_size - box_size) / 2, 0, box_size, box_size);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int idx = (int)e.Data;
                    CircleParameters circle = circle_parameters [idx];
                    double           x1, y1;

                    x1 = y1 = radius + margin;

                    DrawCircle(e.Context, x1, y1, circle.Colors, start_indices [idx]);
                    e.Context.DrawTextCentered(e.Width / 2, box_size + text_offset,
                                               Answer.GetFigureName(idx));
                    e.Context.Stroke();
                };
                container.AddChild(drawable_area);
            }
        }
Ejemplo n.º 28
0
        protected override void Initialize()
        {
            int pair = random.Next(pairs);

            question = (char)(48 + question_answer[pair * 2]);

            char num = (char)(48 + question_answer[(pair * 2) + 1]);

            Answer.Correct = num.ToString();

            Container    container;
            DrawableArea drawable_area;
            double       x = DrawAreaX + 0.1;
            double       y = DrawAreaY + 0.2;

            container = new Container();
            AddWidget(container);

            drawable_area        = new DrawableArea(x + 0.1, y, figure_size, figure_size);
            drawable_area.DataEx = "1";
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.Rectangle(0, 0, figure_size, figure_size);
                e.Context.Stroke();
                e.Context.MoveTo(txtoff_x, txtoff_y);
                e.Context.ShowPangoText("1");
            };

            drawable_area        = new DrawableArea(x + 0.2, y, figure_size, figure_size);
            drawable_area.DataEx = "2";
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.Rectangle(0, 0, figure_size, figure_size);
                e.Context.Stroke();
                e.Context.MoveTo(txtoff_x, txtoff_y);
                e.Context.ShowPangoText("2");
            };

            drawable_area        = new DrawableArea(x + 0.2, y + 0.1, figure_size, figure_size);
            drawable_area.DataEx = "3";
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.Rectangle(0, 0, figure_size, figure_size);
                e.Context.Stroke();
                e.Context.MoveTo(txtoff_x, txtoff_y);
                e.Context.ShowPangoText("3");
            };

            drawable_area        = new DrawableArea(x + 0.3, y + 0.1, figure_size, figure_size);
            drawable_area.DataEx = "4";
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.Rectangle(0, 0, figure_size, figure_size);
                e.Context.Stroke();
                e.Context.MoveTo(txtoff_x, txtoff_y);
                e.Context.ShowPangoText("4");
            };

            drawable_area        = new DrawableArea(x + 0.4, y + 0.1, figure_size, figure_size);
            drawable_area.DataEx = "5";
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.Rectangle(0, 0, figure_size, figure_size);
                e.Context.Stroke();
                e.Context.MoveTo(txtoff_x, txtoff_y);
                e.Context.ShowPangoText("5");
            };

            drawable_area        = new DrawableArea(x + 0.4, y + 0.2, figure_size, figure_size);
            drawable_area.DataEx = "6";
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.Rectangle(0, 0, figure_size, figure_size);
                e.Context.Stroke();
                e.Context.MoveTo(txtoff_x, txtoff_y);
                e.Context.ShowPangoText("6");
            };
        }
Ejemplo n.º 29
0
        protected override void Initialize()
        {
            bool duplicated;
            int  options_next, which = 0;

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;

            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                total_size = 10;
                break;

            case GameDifficulty.Medium:
            case GameDifficulty.Master:
                total_size = 15;
                break;
            }

            GetPuzzleNumbersAndAnswer();

            options = new int [options_cnt];
            options [correct_pos] = correct;
            options_next          = correct_pos + 1;

            // Generate possible answers
            while (options_next < options_cnt)
            {
                int ans;

                ans        = correct + random.Next(-correct / 2, correct / 2);
                duplicated = false;

                // No repeated answers
                for (int num = 0; num < options_next; num++)
                {
                    if (options [num] == ans)
                    {
                        duplicated = true;
                        break;
                    }
                }

                if (duplicated)
                {
                    continue;
                }

                options [options_next] = ans;
                options_next++;
            }

            random_indices = new ArrayListIndicesRandom(options_cnt);
            random_indices.Initialize();

            for (int i = 0; i < options_cnt; i++)
            {
                if (random_indices [i] == correct_pos)
                {
                    which = i;
                    break;
                }
            }

            Answer.SetMultiOptionAnswer(which, options [correct_pos].ToString());

            // Options
            double    x = DrawAreaX + 0.25, y = DrawAreaY + 0.26;
            Container container = new Container(x, y, 1 - (x * 2), 0.6);

            AddWidget(container);

            for (int i = 0; i < options_cnt; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.3, 0.1);
                drawable_area.X = x;
                drawable_area.Y = y + i * 0.15;
                container.AddChild(drawable_area);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n    = (int)e.Data;
                    int indx = random_indices[n];

                    e.Context.SetPangoLargeFontSize();
                    e.Context.MoveTo(0.02, 0.02);
                    e.Context.ShowPangoText(String.Format("{0}) {1}", Answer.GetMultiOption(n), options [indx]));
                };
            }
        }
Ejemplo n.º 30
0
        protected override void Initialize()
        {
            int fig1, fig2;

            switch (CurrentDifficulty)
            {
            case GameDifficulty.Easy:
                figures_active = 4;
                rows           = columns = 3;
                break;

            case GameDifficulty.Medium:
                figures_active = 6;
                rows           = 3;
                columns        = 4;
                break;

            case GameDifficulty.Master:
                figures_active = 8;
                columns        = rows = 4;
                break;
            }

            rect_w  = 0.65 / columns;
            rect_h  = 0.65 / rows;
            figures = new ArrayListIndicesRandom(figures_active * 2);
            figures.Initialize();
            question_pos = random.Next(figures_active * 2);

            for (int figure = 0; figure < figures_active * 2; figure++)
            {
                if (figure == question_pos)
                {
                    continue;
                }

                fig1 = figures[figure];
                fig2 = figures[question_pos];

                if (fig1 >= figures_active)
                {
                    fig1 -= figures_active;
                }
                if (fig2 >= figures_active)
                {
                    fig2 -= figures_active;
                }

                if (fig1 == fig2)
                {
                    question_answer = figure + 1;
                    break;
                }
            }
            Answer.Correct = question_answer.ToString();
            base.Initialize();

            // Answers controls
            int    col = 0;
            double y   = start_y;

            HorizontalContainer container = new HorizontalContainer(start_x_ans, y, columns * rect_w, rect_h);

            AddWidget(container);

            for (int figure = 0; figure < figures.Count; figure++, col++)
            {
                if (col >= columns)
                {
                    col = 0;
                    y  += rect_h;

                    container = new HorizontalContainer(start_x_ans, y, columns * rect_w, rect_h);
                    AddWidget(container);
                }

                DrawableArea drawable_area = new DrawableArea(rect_w, rect_h);
                container.AddChild(drawable_area);
                drawable_area.DataEx = (figure + 1).ToString();

                if (figure == question_pos)
                {
                    int fig = figures[figure];
                    if (fig >= figures_active)
                    {
                        fig -= figures_active;
                    }

                    drawable_area.Data              = fig;
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawFigure(e.Context, 0, 0, (FigureType)e.Data);
                    };
                }
                else
                {
                    drawable_area.Data              = figure + 1;
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        int n = (int)e.Data;

                        e.Context.SetPangoLargeFontSize();
                        e.Context.DrawTextCentered(rect_w / 2, rect_h / 2, (n).ToString());
                        e.Context.Stroke();
                    };
                }
            }
        }