Пример #1
0
        public void PlayAgain()
        {
            // reset player and obstacles
            Player.Reset();
            ResetAllObstacles();
            //create new obastakels
            obstacles = new Obstacles(amountTree, amountBomb, amountMoving, amountCoin, randomLevel);
            PlaceAllObstacles();
            foreach (Obstacle o in Obstacles.obstacles)
            {
                if (o.GetType().ToString() == "KBSGame.Model.MovingObstacle")
                {
                    MovingObstacle mo = (MovingObstacle)o;
                    mo.deadByMovingObstacle += OnDeadByMovingObstacle;
                }
            }
            //allow player to move again, restart timer
            FreezePlayer = false;
            GameTimer.Restart();
            playing  = true;
            GameWon  = false;
            GameLost = false;

            //check if explosion is on so it can be deleted from screen
            if (explosion)
            {
                ExplosionEnded();
            }

            //set collected coins 0
            CollectedCoins = 0;
            mainWindow.CoinCounter.Content = CollectedCoins;

            //disable endpoint
            if (EndPointIsShown)
            {
                RemoveEndPoint(EndPoint, GameCanvas);
                EndPoint = null;
                Player.endPointReached -= OnEndPointReached;
                EndPointIsShown         = false;
            }
        }