/// <summary> /// Generate a list of targets based in passed in demensions. /// </summary> /// <returns>The targets.</returns> /// <param name="w">Number of horizontal targets.</param> /// <param name="h">Number of vertical targets.</param> public static List <Target> GenTargets(int h, int v, EquationDifficulty diff) { List <Target> grid = new List <Target>(); Random r = new Random(); // rand number generator. Needs to be here to avoid duplicates from being created as it is seeded with time float gap = 40.0f; float x = _border; float y = _border; for (int i = 0; i < h; i++) { for (int j = 0; j < v; j++) { // 2/5 chance of generating an equation if (r.Next(1, 5) < 2) { grid.Add(new EquationTarget(x + ((60 + gap) * i), y + ((60 + gap) * j) + gap, diff, r)); } else // generate normal target with no equation { grid.Add(new Target(x + ((60 + gap) * i), y + ((60 + gap) * j) + gap)); } } } return(grid); }
/// <summary> /// Generates a random equation. /// </summary> /// <returns>The equation.</returns> /// <param name="diff">Diff.</param> /// <param name="r">Random generator. This is needed to get unique rand values each time</param> public static Equation GenEquation(EquationDifficulty diff, Random r) { Equation eq = new Equation(); if (diff == EquationDifficulty.EASY) { eq.val1 = r.Next(0, 10); eq.val2 = r.Next(0, 10); eq.type = (EquationType)r.Next(0, 2); } else if (diff == EquationDifficulty.INTERMEDIATE) { eq.val1 = r.Next(0, 15); eq.val2 = r.Next(0, 15); eq.type = (EquationType)r.Next(0, 3); } else { // hard eq.val1 = r.Next(0, 50); eq.val2 = r.Next(0, 50); eq.type = (EquationType)r.Next(0, 4); } eq.solution = CalcSolution(eq); return(eq); }
/// <summary> /// Generate a list of targets based in passed in demensions. /// </summary> /// <returns>The targets.</returns> /// <param name="w">Number of horizontal targets.</param> /// <param name="h">Number of vertical targets.</param> public static List<Target> GenTargets(int h, int v, EquationDifficulty diff) { List<Target> grid = new List<Target>(); Random r = new Random(); // rand number generator. Needs to be here to avoid duplicates from being created as it is seeded with time float gap = 40.0f; float x = _border; float y = _border; for (int i = 0; i < h; i++) { for (int j = 0; j < v; j++) { // 2/5 chance of generating an equation if (r.Next (1, 5) < 2) grid.Add (new EquationTarget (x + ((60+gap)*i), y + ((60+gap)*j) + gap, diff, r)); else // generate normal target with no equation grid.Add (new Target (x + ((60+gap)*i), y + ((60+gap)*j) + gap)); } } return grid; }
private void NextWave() { EquationDifficulty diff = new EquationDifficulty(); if (_wave >= 10) { diff = EquationDifficulty.HARD; } else if (_wave >= 4) { diff = EquationDifficulty.INTERMEDIATE; } else { diff = EquationDifficulty.EASY; } _wave++; _targets = Target.GenTargets(_wave * 2, _wave * 1, diff); _waveOscilatingDir = Direction.RIGHT; }
private void NextWave() { EquationDifficulty diff = new EquationDifficulty(); if (_wave >= 10) diff = EquationDifficulty.HARD; else if (_wave >= 4) diff = EquationDifficulty.INTERMEDIATE; else diff = EquationDifficulty.EASY; _wave++; _targets = Target.GenTargets (_wave * 2, _wave * 1, diff); _waveOscilatingDir = Direction.RIGHT; }
public EquationTarget(float x, float y, EquationDifficulty diff, Random r) : base(x, y, Color.Red) { _eq = GenEquation(diff, r); }
public EquationTarget(float x, float y, EquationDifficulty diff, Random r) : base(x, y, Color.Red) { _eq = GenEquation (diff, r); }
/// <summary> /// Generates a random equation. /// </summary> /// <returns>The equation.</returns> /// <param name="diff">Diff.</param> /// <param name="r">Random generator. This is needed to get unique rand values each time</param> public static Equation GenEquation(EquationDifficulty diff, Random r) { Equation eq = new Equation (); if (diff == EquationDifficulty.EASY) { eq.val1 = r.Next (0, 10); eq.val2 = r.Next (0, 10); eq.type = (EquationType)r.Next (0, 2); } else if (diff == EquationDifficulty.INTERMEDIATE) { eq.val1 = r.Next (0, 15); eq.val2 = r.Next (0, 15); eq.type = (EquationType)r.Next (0, 3); } else { // hard eq.val1 = r.Next (0, 50); eq.val2 = r.Next (0, 50); eq.type = (EquationType)r.Next (0, 4); } eq.solution = CalcSolution(eq); return eq; }