public void Generate()
 {
     for (int i = 0; i < numUnits; i++)
     {
         if (r.Next(0, 2) == 0)
         {
             MeleeUnit m = new MeleeUnit(r.Next(0, mapW), r.Next(0, mapH), "Soldier", 100, 3, 20, i % 2 == 0 ? 1 : 0, "M");
             units.Add(m);
             numM++;
         }
         else
         {
             RangedUnit ru = new RangedUnit(r.Next(0, mapW), r.Next(0, mapH), "Archer", 100, 2, 20, 5, i % 2 == 0 ? 1 : 0, "R");
             units.Add(ru);
             numR++;
         }
     }
     for (int j = 0; j < numBuilds; j++)
     {
         if (r.Next(0, 2) == 0)
         {
             if (r.Next(0, 2) == 0)
             {
                 FactoryBuilding fb = new FactoryBuilding(r.Next(0, mapW), r.Next(0, mapH), 0, 200, 5, j % 2 == 0 ? 1 : 0, "FB");
                 builds.Add(fb);
             }
             else
             {
                 FactoryBuilding fb = new FactoryBuilding(r.Next(0, mapW), r.Next(0, mapH), 1, 200, 5, j % 2 == 0 ? 1 : 0, "FB");
                 builds.Add(fb);
             }
         }
         else
         {
             ResourceBuilding rb = new ResourceBuilding(r.Next(0, mapW), r.Next(0, mapH), "Swords", 200, 2, 60, j % 2 == 0 ? 1 : 0);
             builds.Add(rb);
         }
     }
     if (numR < numM)
     {
         for (int k = 0; k < r.Next(numR, numM); k++)
         {
             WizardUnit wu = new WizardUnit(r.Next(0, mapW), r.Next(0, mapH), "Wizro", 70, 1, 30, 3, "W");
             units.Add(wu);
         }
     }
     else
     {
         for (int k = 0; k < r.Next(numM, numR); k++)
         {
             WizardUnit wu = new WizardUnit(r.Next(0, mapW), r.Next(0, mapH), "Wizro", 70, 1, 30, 3, "W");
             units.Add(wu);
         }
     }
 }
        public Unit Spawn(FactoryBuilding spawner, List <Building> builds)
        {
            ResourceBuilding res = (ResourceBuilding)builds[tempSpot];

            if (spawner.UnitType() == 0)
            {
                res.Pool -= 4;
                RangedUnit r = new RangedUnit(spawner.PosX, spawner.spawnPoint, "archer", 100, 1, 20, 5, spawner.Faction, "R");
                return(r);
            }
            else
            {
                res.Pool -= 5;
                MeleeUnit m = new MeleeUnit(spawner.PosX, spawner.spawnPoint, "soldier", 100, 1, 20, spawner.Faction, "M");
                return(m);
            }
        }