protected override void Initialize() { bool done = false; switch (CurrentDifficulty) { case GameDifficulty.Easy: colors_shown = 3; break; case GameDifficulty.Medium: colors_shown = 4; break; case GameDifficulty.Master: colors_shown = 6; break; } palette = new ColorPalette (Translations); // It is not acceptable that all the random colors names match the right colors while (done == false) { color_order = new ArrayListIndicesRandom (colors_shown); color_order.Initialize (); for (int i = 0; i < colors_shown; i++) { if (palette.Name (color_order [i]) != palette.Name (i)) { done = true; break; } } } question = random.Next (colors_shown); Answer.Correct = palette.Name (color_order [question]); question_colorname = palette.Name (question); base.Initialize (); }
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 (); }; } }
void DrawAnswer(CairoContextEx gr, double x, double y) { ColorPalette palette = new ColorPalette (Translations); gr.Save (); // A full sized square of paper gr.Color = palette.Cairo (ColorPalette.Id.Yellow); gr.Rectangle (x, y, width, height); gr.Fill (); gr.Stroke (); // 3/4 of the whole size square of paper in the bottom right corner gr.Color = palette.Cairo (ColorPalette.Id.Blue); double w = 3d/4d * width; double h = 3d/4d * height; gr.Rectangle (x + (width - w), y + (height - h), w, h); gr.Fill (); gr.Stroke (); // 3/4 square of paper in the top left corner gr.Color = palette.Cairo (ColorPalette.Id.Green); gr.Rectangle (x, y, 3d/4d * width, 3d/4d * height); gr.Fill (); gr.Stroke (); // 1/4 square of paper in the top left corner gr.Color = palette.Cairo (ColorPalette.Id.Red); gr.Rectangle (x, y, 1d/4d * width, 1d/4d * height); gr.Fill (); gr.Stroke (); gr.Restore (); }
protected override void Initialize() { ArrayListIndicesRandom random_indices = new ArrayListIndicesRandom (total_slices); Color clr; cp = new ColorPalette (); 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); } }
protected override void Initialize() { switch (CurrentDifficulty) { case GameDifficulty.Easy: maxdotscolor = 2; break; case GameDifficulty.Medium: maxdotscolor = 5; break; case GameDifficulty.Master: maxdotscolor = 8; break; } location_order = new ArrayListIndicesRandom (NUMCOLUMNS*NUMCOLUMNS); location_order.Initialize(); palette = new ColorPalette (); // dotsPerColor is compared with iterator of dots. (this iterator is 0 based, so I // have to substract 1 to make dotsPerColor contents 0 based. dotsPerColor = new int [palette.Count]; for (int i=0,before=-1; i< palette.Count; i++) { dotsPerColor[i] = before + MINDOTS + random.Next(maxdotscolor-MINDOTS+1); before = dotsPerColor[i]; } Answer.Correct = (dotsPerColor[0]+1).ToString (); base.Initialize (); }
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 (); }; } }