/// <summary> /// Called when the balance has stopped moving and is good to go /// </summary> public void VerifySolution() { if (LeftBalanceBalls.Count > 0) { if (LeftBalanceBalls.Sum(s => s.Weight) == RightBalanceBalls.Sum(s => s.Weight)) { if (LevelCompleted != null) { Score++; LevelCompleted(this, EventArgs.Empty); // Let's make life interesting ;) if (currentMode == Mode.Challenge) { TimeLeft += Convert.ToInt32(Math.Log(currentLevel) * (_twoPlayerMode ? 6 : 2)); } currentLevel++; } if (currentMode == Mode.Classic) { TimeLeft = _classicLevelTime; } } else if (!_twoPlayerMode || RightBalanceBalls.Any(s => s is Bird)) { if (currentMode == Mode.Classic) { this.LivesLeft--; } if (LivesLeft > 0) { if (LevelLost != null) { LevelLost(this, new LevelLostEventArgs(LevelLostEventArgs.Reason.WrongAnswer)); } } else { gameTimer.Stop(); if (GameOver != null) { GameOver(this, EventArgs.Empty); } } if (currentMode == Mode.Classic) { TimeLeft = _classicLevelTime; } } } }
// Gets the amount of weight the right side is heavier than the left public double GetBalanceOffset() { return(RightBalanceBalls.Sum(s => s.Weight) - LeftBalanceBalls.Sum(s => s.Weight)); }