Ejemplo n.º 1
0
        private IEnumerable <Player> GetProximity(TimeSpan start, TimeSpan end, IEnumerable <Player> alive, Replay replay)
        {
            IEnumerable <Unit> teamOne = alive.SelectMany(p => p.HeroUnits.Where(unit => replayHelper.IsHero(unit) && unit.PlayerControlledBy.Team == 1 && replayHelper.IsAlive(unit, start, end)));
            IEnumerable <Unit> teamTwo = alive.SelectMany(p => p.HeroUnits.Where(unit => replayHelper.IsHero(unit) && unit.PlayerControlledBy.Team == 0 && replayHelper.IsAlive(unit, start, end)));

            foreach (Unit teamOneUnit in teamOne)
            {
                foreach (Unit teamTwoUnit in teamTwo)
                {
                    foreach (Position teamOnePosition in teamOneUnit.Positions.Where(p => replayHelper.IsWithin(p.TimeSpan, start, end)))
                    {
                        foreach (Position teamTwoPosition in teamTwoUnit.Positions.Where(p => replayHelper.IsWithin(p.TimeSpan, start, end)))
                        {
                            double distance = teamOnePosition.Point.DistanceTo(teamTwoPosition.Point);

                            // proximity to other players
                            if (distance <= settings.MaxDistanceToEnemy)
                            {
                                logger.LogDebug($"GetProximity: {distance}, heroes: {teamOneUnit.PlayerControlledBy.HeroId}, {teamTwoUnit.PlayerControlledBy.HeroId}");

                                yield return(teamOneUnit.PlayerControlledBy);

                                yield return(teamTwoUnit.PlayerControlledBy);
                            }
                            else
                            {
                                // beacons, map regen globes etc
                                foreach (Unit unit in replay.Units.Where(u => replayHelper.IsCapturePoint(u) || replayHelper.IsMapObjective(u)))
                                {
                                    if (unit.PointBorn.DistanceTo(teamOnePosition.Point) <= settings.MaxDistanceToObjective)
                                    {
                                        yield return(teamOneUnit.PlayerControlledBy);
                                    }

                                    if (unit.PointBorn.DistanceTo(teamTwoPosition.Point) <= settings.MaxDistanceToObjective)
                                    {
                                        yield return(teamTwoUnit.PlayerControlledBy);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }