Esempio n. 1
0
        // Om een bepaalde tijd het spel een stap laten doen
        private void MakeStep()
        {
            int scoreToAdd;

            while (running)
            {
                timeLeft = calculateRoundTime();
                while (timeLeft > 0)
                {
                    Thread.Sleep(100);
                    timeLeft = (timeLeft - 100);
                    Console.Clear();
                    outputview.ShowGame(bord, score, timeLeft, boot, boot2);
                }

                // score controleren bij elke stap
                scoreToAdd = bord.stap();
                if (scoreToAdd == -1)// score -1 betekend wagons gebotst
                {
                    outputview.GameEnd(score);
                    Environment.Exit(0);
                }
                else // score toevoegen

                {
                    addCartCounter++;
                }
                if (addCartCounter == 2)
                {
                    bord.addRandom();
                    addCartCounter = 0;
                }

                BootCounter++;

                if (BootCounter == 12)
                {
                    if (boot.lading == 8)
                    {
                        score = score + 10;
                    }
                    if (boot2.lading == 8)
                    {
                        score = score + 10;
                    }
                    boot  = null;
                    boot2 = null;
                }
                if (BootCounter == 17)
                {
                    boot2       = new Schip();
                    boot        = new Schip();
                    BootCounter = 0;
                }

                if (BootCounter > 0 &&
                    BootCounter < 12)
                {
                    score = score + scoreToAdd;

                    scoreToAdd = 0;
                }
            }
        }