public IEnumerable <Invader> GenerateWave(GridDestination horizontal, GridDestination vertical, IEnumerable <Piece> pieces, GridCell[,] grid)
        {
            // create a list to store the invaders created
            List <Invader> retval = new List <Invader>();

            // if the invader level is past the maximum, then return an empty invader list
            if (SentAllInvaders)
            {
                return(retval);
            }

            // TODO: This could be something to adjust based on the difficulty
            // decide how many invaders we're going to send
            int invaderCount = 10;

            // create a class that holds the default weights of everything
            InvaderLevelUpInfo info = new InvaderLevelUpInfo(pieces, mMadeItCount, mDestroyedCount);

            // now then, create a loop to generate the invaders
            for (int i = 0; i < invaderCount; ++i)
            {
                // determine the boolean properties for the invader
                bool flying    = RandomGenerator.NextBool();
                bool leftRight = RandomGenerator.NextBool();

                // get the start/goal and key
                GridCell     start = leftRight ? horizontal.Start : vertical.Start;
                GridCell     goal  = leftRight ? horizontal.End : vertical.End;
                DijkstraType key   = leftRight ? DijkstraType.LeftToRight : DijkstraType.TopToBottom;

                // create a base invader. This invader will have a 50% chance of flying.
                Invader invader = new Invader(this, flying);

                // set the experience of the invader given the weights
                invader.LevelUp((InvaderLevel * 10), InvaderLevel, info);

                // send the invader to the map
                invader.BriefOnMission(start, goal, key);

                // next, add the invader to the list
                retval.Add(invader);
            }

            // increase the level
            ++InvaderLevel;

            // if we increased the level to the maximum invader level, then we've sent all of the invaders
            if (InvaderLevel > Invader.MaxInvaderLevel)
            {
                SentAllInvaders = true;
                InvaderLevel    = Invader.MaxInvaderLevel;
            }

            // return the invaders
            return(retval);
        }
        private void GenerateNextWave()
        {
            // get the data needed for the mothership
            GridDestination horizontal = new GridDestination(HorzStartCell, HorzGoalCell);
            GridDestination vertical   = new GridDestination(VertStartCell, VertGoalCell);

            // generate the next wave
            IEnumerable <Invader> invaders = invaderMothership.GenerateWave(horizontal, vertical, mPieces, Grid);

            mInvaders.AddRange(invaders);

            // trigger the design phase as over
            if (Player.State == PlayerState.Designing)
            {
                Player.TriggerDesignPhaseOver();
            }

            // sort the invaders so that the flying ones are drawn last
            mInvaders.Sort((a, b) => a.Flying.CompareTo(b.Flying));
        }