当前位置: 首页>>代码示例>>C#>>正文


C# GameState.HuntersWithinDistanceOf方法代码示例

本文整理汇总了C#中FuryOfDracula.GameLogic.GameState.HuntersWithinDistanceOf方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.HuntersWithinDistanceOf方法的具体用法?C# GameState.HuntersWithinDistanceOf怎么用?C# GameState.HuntersWithinDistanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FuryOfDracula.GameLogic.GameState的用法示例。


在下文中一共展示了GameState.HuntersWithinDistanceOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateStrategy

        public void UpdateStrategy(GameState game)
        {
            int turnsUntilDark = 0;
            int turnsUntilLight = 0;
            if ((int)game.TimeOfDay > 3)
            {
                turnsUntilLight = 7 - (int)game.TimeOfDay;
            }
            if ((int)game.TimeOfDay < 4)
            {
                turnsUntilDark = 4 - (int)game.TimeOfDay;
            }

            // if there are any hunters in range
            var potentialVictims = game.HuntersWithinDistanceOf(game.Dracula.CurrentLocation, turnsUntilLight);
            var victimsToEliminate = new List<HunterPlayer>();
            foreach (HunterPlayer h in potentialVictims)
            {
                // eliminate any that have a stake
                if (h.LikelihoodOfHavingItemOfType(game, Item.Stake) > 0.5)
                {
                    // unless they only have 1 and I have a rage card that can discard it
                    if (h.LikelihoodOfHavingItemOfType(game, Item.Stake) < 2 && game.Dracula.EventHand.Any(card => card.Event == Event.Rage))
                    {
                        // but if someone can cancel my rage card and I can't cancel their good luck
                        if (game.Dracula.EventHand.Count(card => card.Event == Event.DevilishPower) - game.LikelihoodOfAnyHunterHavingEventOfType(Event.GoodLuck) < 0.5)
                        {
                            victimsToEliminate.Add(h);
                            continue;
                        }
                    }
                    else
                    {
                        victimsToEliminate.Add(h);
                        continue;
                    }
                }
                // elminate any that have Heavenly Host
                if (h.LikelihoodOfHavingItemOfType(game, Item.HeavenlyHost) > 0.75)
                {
                    // unless they only have 1 and I have a rage card that can discard it
                    if (h.LikelihoodOfHavingItemOfType(game, Item.HeavenlyHost) < 2 && game.Dracula.EventHand.Any(card => card.Event == Event.Rage))
                    {
                        // but if someone can cancel my rage card and I can't cancel their good luck
                        if (game.Dracula.EventHand.Count(card => card.Event == Event.DevilishPower) - game.LikelihoodOfAnyHunterHavingEventOfType(Event.GoodLuck) < 0.5)
                        {
                            victimsToEliminate.Add(h);
                            continue;
                        }
                    }
                    else
                    {
                        victimsToEliminate.Add(h);
                        continue;
                    }
                }
            }
            foreach (HunterPlayer h in victimsToEliminate)
            {
                potentialVictims.Remove(h);
            }
            potentialVictims.Clear();
            // if there are any that are in the same location as someone who is not a potential victim, I don't want to attack them both
            foreach (HunterPlayer h in potentialVictims)
            {
                for (int i = 1; i < 5; i++)
                {
                    if (!potentialVictims.Contains(game.Hunters[i]) && h.CurrentLocation == game.Hunters[i].CurrentLocation)
                    {
                        victimsToEliminate.Add(h);
                    }
                }
            }
            foreach (HunterPlayer h in victimsToEliminate)
            {
                potentialVictims.Remove(h);
            }

            if (potentialVictims.Any())
            {
                // if it's worth breaking cover to attack
                if ((NumberOfPossibleCurrentLocations < 6 && potentialVictims.Any(hunter => LikelihoodOfHunterDeath(game, hunter) > LikelihoodOfDraculaDeath(game.Dracula.Blood))) || (game.Vampires > 3 && potentialVictims.Any(hunter => LikelihoodOfHunterDeath(game, hunter) > 25)))
                {
                    float highestLikelihoodOfDeath = 0;
                    foreach (HunterPlayer hunter in potentialVictims)
                    {
                        if (LikelihoodOfHunterDeath(game, hunter) > highestLikelihoodOfDeath)
                        {
                            victim = hunter;
                            highestLikelihoodOfDeath = LikelihoodOfHunterDeath(game, hunter);
                        }
                    }
                    if (victim != null)
                    {
                        Strategy = Strategy.Aggressive;
                        return;
                    }
                }
            }

//.........这里部分代码省略.........
开发者ID:UncleGus,项目名称:dracula,代码行数:101,代码来源:DecisionMaker.cs


注:本文中的FuryOfDracula.GameLogic.GameState.HuntersWithinDistanceOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。