Beispiel #1
0
 private void SetupLevel()
 {
     if (LevelReset != null)
     {
         LevelReset(null, EventArgs.Empty);
     }
     PlayerOneHeldBalls.Clear();
     PlayerTwoHeldBalls.Clear();
     LeftBalanceBalls.Clear();
     RightBalanceBalls.Clear();
     foreach (var weight in curOneBalls)
     {
         PlayerOneHeldBalls.Add(new Bird(weight.ToString(), weight));
     }
     if (curTwoBalls != null)
     {
         foreach (var weight in curTwoBalls)
         {
             PlayerTwoHeldBalls.Add(new Bird(weight.ToString(), weight));
         }
     }
     foreach (var weight in targetRightSide)
     {
         RightBalanceBalls.Add(new Pig(weight.ToString(), weight));
     }
 }
Beispiel #2
0
 /// <summary>
 /// Adds a ball to the balance
 /// </summary>
 /// <param name="ball"></param>
 /// <param name="leftSide"></param>
 public void AddBallToBalance(SeesawObject ball, bool leftSide)
 {
     if (leftSide)
     {
         LeftBalanceBalls.Add(ball);
     }
     else
     {
         RightBalanceBalls.Add(ball);
     }
 }
Beispiel #3
0
 /// <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;
             }
         }
     }
 }
Beispiel #4
0
 // 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));
 }