Exemple #1
0
        public static BaseUnitPackage GetUnit(int RandomNumber, int level)
        {
            List <BaseUnitPackage> ListOfUnits = null;

            //Point ListOfUnits to a certain list to aquire units from depending on a level
            for (int i = 0; i < 5; i++)
            {
                if (RandomNumber <= UnitsGatheringMatrix[level - 1, i])
                {
                    ListOfUnits = UnitTypes[i];
                    break;
                }
            }

            //If it didn't come to an error take a unit from the list
            if (ListOfUnits != null && ListOfUnits.Count != 0)
            {
                RandomNumber = rand.Next(ListOfUnits.Count);
                BaseUnitPackage Unit = ListOfUnits[RandomNumber];
                ListOfUnits.RemoveAt(RandomNumber);
                return(Unit);
            }
            //if list is empty get another unit via recursion
            else if (ListOfUnits.Count == 0 || ListOfUnits == null)
            {
                return(GetUnitsV2(new List <bool>()
                {
                    true, true, true, true, true
                }, RandomNumber, level));
                //return GetUnit(rand.Next(0,99), level);
            }
            return(null);
        }
Exemple #2
0
        public static void PutUnitInPool(BaseUnitPackage unit)
        {
            int rarity = 0;

            switch (unit.Cost)
            {
            case 1:
                rarity = 0;
                break;

            case 2:
            case 3:
                rarity = 1;
                break;

            case 4:
            case 5:
                rarity = 2;
                break;

            case 6:
            case 7:
                rarity = 3;
                break;

            default:
                rarity = 4;
                break;
            }
            UnitTypes[rarity].Add(unit);
        }
Exemple #3
0
        private static void InitializeUnitsOf(BaseUnitPackage unit)
        {
            int numCopies = 0;

            switch (unit.Cost)
            {
            case 1:
                numCopies = 45;
                break;

            case 2:
            case 3:
                numCopies = 30;
                break;

            case 4:
            case 5:
                numCopies = 25;
                break;

            case 6:
            case 7:
                numCopies = 15;
                break;

            default:
                numCopies = 10;
                break;
            }
            for (int i = 1; i < numCopies; ++i)
            {
                PutUnitInPool(unit.Clone());
            }
            PutUnitInPool(unit);
        }
Exemple #4
0
 public void ReturnUnitToPool(BaseUnitPackage unit)
 {
     UnitsPool.PutUnitInPool(unit);
 }