Пример #1
0
        public static void PositionFoes(List <Foe> foes)
        {
            Random rnd = new Random();

            for (int cnt = 0; cnt < foes.Count; cnt++)
            {
                Foe  f         = foes[cnt];
                bool uniquePos = false;
                int  rndRow    = 1;
                int  rndCol    = 1;

                while (!uniquePos)
                {
                    rndRow = rnd.Next(2, 7);
                    rndCol = rnd.Next(1, 4);

                    // if we don't already have a foe in this position, use it
                    if (foes.Count(f => f.Col == rndCol && f.Row == rndRow) == 0)
                    {
                        f.Col     = rndCol;
                        f.Row     = rndRow;
                        uniquePos = true;
                    }
                }
                f.GridArea = $" {rndRow} / {rndCol} / {rndRow + 1} / {rndCol + 1} ";
            }
        }
Пример #2
0
        public static List <Foe> GetNewLobby()
        {
            List <Foe> _foes          = new List <Foe>();
            int        PERCENT_ELITES = 10;
            Random     rnd            = new Random();

            // generate 5 random foes
            for (int cnt = 0; cnt < 5; cnt++)
            {
                Foe foe = new Foe();
                foe.Stars = (StarName)rnd.Next(3, 6);

                int foetype = rnd.Next(1, 7);
                foe.Type = (FoeType)foetype;

                int isElite = rnd.Next(1, PERCENT_ELITES);
                foe.Elite = (isElite == 1) ? true : false;

                _foes.Add(foe);
            }
            return(_foes.ToList());
        }