コード例 #1
0
ファイル: EnemyPicker.cs プロジェクト: cvance5/Dirty-World
        public static List <EnemyTypes> RequestEnemies(int riskPoints, EnemyRequestCriteria requestCriteria)
        {
            var enemies = new List <EnemyTypes>();

            while (riskPoints > 0)
            {
                var foundSomething = false;

                // Suffle all enemies, taking only ones we can afford
                var possibleEnemies = _requirementsForEnemy
                                      .Where(requirement => requirement.Value.RiskPointCost <= riskPoints)
                                      .OrderBy(requirement => Chance.Percent);

                foreach (var possibleEnemy in possibleEnemies)
                {
                    // If this random enemy works, save it, pay the bill, and reshuffle
                    if (possibleEnemy.Value.Compare(requestCriteria))
                    {
                        enemies.Add(possibleEnemy.Key);
                        riskPoints    -= possibleEnemy.Value.RiskPointCost;
                        foundSomething = true;
                        break;
                    }
                }

                if (!foundSomething)
                {
                    break;                  // Nothing left that meets our criteria
                }
            }

            return(enemies);
        }
コード例 #2
0
ファイル: EnemyPicker.cs プロジェクト: cvance5/Dirty-World
            public bool Compare(EnemyRequestCriteria criteria)
            {
                if (!criteria.HeightsAllowed?.IsInRange(Height) ?? false)
                {
                    return(false);
                }

                if (!criteria.LengthsAllowed?.IsInRange(Length) ?? false)
                {
                    return(false);
                }

                return(true);
            }