コード例 #1
0
ファイル: RoastAction.cs プロジェクト: norniel/Game
        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>>();
        }
コード例 #2
0
ファイル: CreateSharpStone.cs プロジェクト: norniel/Game
        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;
            }
        }
コード例 #3
0
ファイル: CutAction.cs プロジェクト: norniel/Game
        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 };
            }
        }
コード例 #4
0
        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 };
            }
        }
コード例 #5
0
ファイル: MakeFire.cs プロジェクト: norniel/Game
        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();
            }
        }
コード例 #6
0
ファイル: BurnAction.cs プロジェクト: norniel/Game
        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());
        }