private void HandleTargetCollision() { foreach (Target t in _targets.ToArray()) { foreach (RectangleShape b in _player.bullets.ToArray()) { if (Target.HasBulletHitTarget(b, t)) { if (t is EquationTarget) { EquationTarget eqTarget = (EquationTarget)t; eqTarget.Selected(); Console.WriteLine("{0} {1} {2} = {3}", eqTarget.GetEquation.val1, eqTarget.GetEquation.type.ToString(), eqTarget.GetEquation.val2, eqTarget.GetEquation.solution); _isSolving = true; _eqToSolve = eqTarget; } else { // only remove now if normal target // equation targets get removed after being solved _targets.Remove(t); // normal target hit _score += 10; } _player.RemoveBullet(b); break; } } } }
public void TestEquationAdditionSolution() { Equation eq = new Equation(); eq.val1 = 5; eq.val2 = 5; eq.type = EquationType.ADDITION; // 5 + 5 = 10 Assert.AreEqual(10, EquationTarget.CalcSolution(eq)); }
public void TestEquationDivisionSolution() { Equation eq = new Equation(); eq.val1 = 5; eq.val2 = 5; eq.type = EquationType.DIVISISON; // 5 / 5 = 1 Assert.AreEqual(1, EquationTarget.CalcSolution(eq)); }
public void TestEquationMultiplicationSolution() { Equation eq = new Equation(); eq.val1 = 5; eq.val2 = 5; eq.type = EquationType.MULTIPLICATION; // 5 x 5 = 25 Assert.AreEqual(25, EquationTarget.CalcSolution(eq)); }
public void TestEquationSubtractionSolution() { Equation eq = new Equation(); eq.val1 = 5; eq.val2 = 5; eq.type = EquationType.SUBTRACTION; // 5 - 5 = 0 Assert.AreEqual(0, EquationTarget.CalcSolution(eq)); }
public EquasionInvasion() { SetupWindow(); // setup player screenRect = new FloatRect (_window.Position.X, _window.Position.Y, _window.Size.X, _window.Size.Y); _player = new Player(screenRect); // initilise fields _targets = new List<Target> (); _isSolving = false; _eqToSolve = new EquationTarget(); _eqCurrentInput = ""; _score = 0; // loaf font _font = new Font("nk57-monospace-no-bk.ttf"); }
public EquasionInvasion() { SetupWindow(); // setup player screenRect = new FloatRect(_window.Position.X, _window.Position.Y, _window.Size.X, _window.Size.Y); _player = new Player(screenRect); // initilise fields _targets = new List <Target> (); _isSolving = false; _eqToSolve = new EquationTarget(); _eqCurrentInput = ""; _score = 0; // loaf font _font = new Font("nk57-monospace-no-bk.ttf"); }
private void HandleTargetCollision() { foreach (Target t in _targets.ToArray()) { foreach (RectangleShape b in _player.bullets.ToArray()) { if (Target.HasBulletHitTarget (b, t)) { if (t is EquationTarget) { EquationTarget eqTarget = (EquationTarget)t; eqTarget.Selected (); Console.WriteLine ("{0} {1} {2} = {3}", eqTarget.GetEquation.val1, eqTarget.GetEquation.type.ToString (), eqTarget.GetEquation.val2, eqTarget.GetEquation.solution); _isSolving = true; _eqToSolve = eqTarget; } else { // only remove now if normal target // equation targets get removed after being solved _targets.Remove (t); // normal target hit _score += 10; } _player.RemoveBullet (b); break; } } } }