Пример #1
0
        public static void TryToCatchRobber(List <Robber> robbers, List <Cop> cops, out int robbersCaught)
        {
            robbersCaught = 0;
            foreach (Robber robber in robbers)
            {
                if (!robber.StolenGoods.Any()) // om rånaren inte har något i sin inventory är han ännu inte en rånare (eller har avtjänat sitt straff)
                {
                    continue;
                }
                Cop cop = cops[Initialize.rand.Next(cops.Count)];
                cop.TakeGoodsFromRobber(robber); // en slumpad polis tar rånarens saker (om det är flera på samma ställe)
                robber.TimesCaught++;
                cop.RobbersBusted++;
                GameField.AddMarker(robber.VerticalPosition, robber.HorizontalPosition, 'A');

                ConsoleFunctions.ShowLocations();
                SomeoneBusted(cop, robber);
                //RobberCaughtPrint(gameField, cop, robber, width, height); //gammal kod!
                robbersCaught++;
            }
        }