public override IEnumerable<List<GameObject>> GetActionsWithNecessaryObjects(IEnumerable<GameObject> objects, Hero hero) { var roastingObjects = hero.GetContainerItems() .Where(o => o.Properties.Contains(Property.Roastable) && o is IRoastable) .GroupBy(o => o.GetType()) .Select(gr => gr.Take(3)); var twig = hero.GetContainerItems().OfType<Twig>().FirstOrDefault(); if (twig != null) return roastingObjects.Select(bo => bo.Union(new List<GameObject> {twig}).Union(objects).ToList()); return new List<List<GameObject>>(); }
public IEnumerable<List<GameObject>> GetActionsWithNecessaryObjects(IEnumerable<GameObject> objects, Hero hero) { var allObjects = objects.Union(hero.GetContainerItems()).Distinct(); var stones = allObjects.Where(o => o is Rock).Take(2).ToList(); if (stones.Count == 2) { yield return stones; } }
public override IEnumerable<List<GameObject>> GetActionsWithNecessaryObjects(IEnumerable<GameObject> objects, Hero hero) { var cuttableObject = objects.FirstOrDefault(o => o.Properties.Contains(Property.Cuttable)); // TODO: implement choosing cutters with different quility var cutter = hero.GetContainerItems().FirstOrDefault(o => o.Properties.Contains(Property.Cutter)); if (cuttableObject != null && cutter != null) { yield return new List<GameObject> { cuttableObject, cutter }; } }
public IEnumerable<List<GameObject>> GetActionsWithNecessaryObjects(IEnumerable<GameObject> objects, Hero hero) { var allObjects = objects.Union(hero.GetContainerItems()).Distinct(); var branch = allObjects.FirstOrDefault(ao => ao is Branch); var stone = allObjects.FirstOrDefault(ao => ao.Properties.Contains(Property.Cutter)); if (branch != null && stone != null) { yield return new List<GameObject> { branch, stone }; } }
public IEnumerable<List<GameObject>> GetActionsWithNecessaryObjects(IEnumerable<GameObject> objects, Hero hero) { var allObjects = objects.Union(hero.GetContainerItems()).Distinct(); var branches = allObjects.Where(ao => ao is Branch).Select(ao => ao).Take(2).ToList(); var plant = allObjects.FirstOrDefault(ao => ao is Plant); if (branches.Count == 2 && plant != null) { branches.Add(plant); yield return branches.ToList(); } }
public IEnumerable<List<GameObject>> GetActionsWithNecessaryObjects(IEnumerable<GameObject> objects, Hero hero) { var burningObjects = hero.GetContainerItems().Where(o => o is IBurnable).GroupBy(o => o.GetType()).Select(gr => gr.First()); return burningObjects.Select(bo => new List<GameObject> {bo}.Union(objects).ToList()); }