private Vector3 DeterminePositionInWorld(IHasLocation element)
        {
            var eventItem        = element.GeoLocation;
            var eastWestLocation = new Location {
                Latitude = CentreOfWorld.Latitude, Longitude = eventItem.Longitude
            };
            var eastWestDistance = eastWestLocation.DistanceInMetres(CentreOfWorld);

            if (eastWestLocation.Longitude < CentreOfWorld.Longitude)
            {
                eastWestDistance *= -1;
            }

            var northSouthDistance = eventItem.DistanceInMetres(eastWestLocation);

            if (eventItem.Latitude > eastWestLocation.Latitude)
            {
                northSouthDistance *= -1;
            }

            // Make sure there's a valid range
            if (VisualRangeInKilometres <= 0)
            {
                VisualRangeInKilometres = 1.0;
            }

            // AddDirectionPoints((int)(-eastWestDistance/ 1000.0), 0, (int)(-northSouthDistance / 1000.0), eventItem.Type);
            return(new Vector3((float)(eastWestDistance / (VisualRangeInKilometres)), 0, (float)(northSouthDistance / (VisualRangeInKilometres))));
        }
Exemple #2
0
        private void FormatHasLocation(IHasLocation hasLocation, StringBuilder result)
        {
            if (hasLocation == null || !IncludePositions)
            {
                return;
            }

            result.AppendFormat("({0}:{1})", hasLocation.Location.Line, hasLocation.Location.Column);
        }
Exemple #3
0
        private IHasLocation ProcessScenarioDefinition(IHasLocation definition, SpecFlowDocument doc)
        {
            if (definition is ScenarioOutline outline)
            {
                return(outline.Clone(examples: outline.Examples.Select(e => HandleTags(e, doc))));
            }

            return(definition);
        }
Exemple #4
0
        private Tuple <Background, Rule, Scenario> ConvertToChild(IHasLocation hasLocation)
        {
            switch (hasLocation)
            {
            case Gherkin.Ast.Background background:
                var backgroundSteps = background.Steps.Select(ConvertStep).ToList();
                return(new Tuple <Background, Rule, Scenario>(new Background
                {
                    Id = _idGenerator.GetNewId(),
                    Location = ConvertLocation(background.Location),
                    Name = CucumberMessagesDefaults.UseDefault(background.Name, CucumberMessagesDefaults.DefaultName),
                    Description = CucumberMessagesDefaults.UseDefault(background.Description, CucumberMessagesDefaults.DefaultDescription),
                    Keyword = background.Keyword,
                    Steps = backgroundSteps
                }, null, null));

            case Ast.Scenario scenario:
                var steps    = scenario.Steps.Select(ConvertStep).ToList();
                var examples = scenario.Examples.Select(ConvertExamples).ToReadOnlyCollection();
                var tags     = scenario.Tags.Select(ConvertTag).ToReadOnlyCollection();
                return(new Tuple <Background, Rule, Scenario>(null, null, new Scenario()
                {
                    Id = _idGenerator.GetNewId(),
                    Keyword = scenario.Keyword,
                    Location = ConvertLocation(scenario.Location),
                    Name = CucumberMessagesDefaults.UseDefault(scenario.Name, CucumberMessagesDefaults.DefaultName),
                    Description = CucumberMessagesDefaults.UseDefault(scenario.Description, CucumberMessagesDefaults.DefaultDescription),
                    Steps = steps,
                    Examples = examples,
                    Tags = tags
                }));

            case Ast.Rule rule:
            {
                var ruleChildren = rule.Children.Select(ConvertToRuleChild).ToReadOnlyCollection();
                var ruleTags     = rule.Tags.Select(ConvertTag).ToReadOnlyCollection();
                return(new Tuple <Background, Rule, Scenario>(null, new Rule
                    {
                        Id = _idGenerator.GetNewId(),
                        Name = CucumberMessagesDefaults.UseDefault(rule.Name, CucumberMessagesDefaults.DefaultName),
                        Description = CucumberMessagesDefaults.UseDefault(rule.Description, CucumberMessagesDefaults.DefaultDescription),
                        Keyword = rule.Keyword,
                        Children = ruleChildren,
                        Location = ConvertLocation(rule.Location),
                        Tags = ruleTags
                    }, null));
            }



            default:
                throw new NotImplementedException();
            }
        }
Exemple #5
0
 public void PlayAll()
 {
     foreach (var item in this.Items)
     {
         IHasLocation temp = item as IHasLocation;
         if (temp != null)
         {
             ChangeDataSource(temp.Location);
             item.Play();
         }
     }
 }
Exemple #6
0
        protected override ILocation GetLocation(UIElement element)
        {
            ContentPresenter contentPresenter = element as ContentPresenter;

            if ((contentPresenter != null) && (contentPresenter.Content != null))
            {
                IHasLocation location = contentPresenter.Content as IHasLocation;
                if (location != null)
                {
                    return(location.Location);
                }
            }
            return(base.GetLocation(element));
        }
        private Children ConvertToChildren(IHasLocation hasLocation)
        {
            switch (hasLocation)
            {
            case Background background:
                return(new Children()
                {
                    Background = new StepsContainer()
                    {
                        Location = ConvertLocation(background.Location),
                        Name = background.Name == string.Empty ? null : background.Name,
                        Keyword = background.Keyword,
                        Steps = background.Steps.Select(s => ConvertStep(s)).ToList()
                    }
                });

            case Scenario scenario:
                return(new Children()
                {
                    Scenario = new StepsContainer()
                    {
                        Keyword = scenario.Keyword,
                        Location = ConvertLocation(scenario.Location),
                        Name = scenario.Name == string.Empty ? null : scenario.Name,
                        Steps = scenario.Steps.Select(s => ConvertStep(s)).ToList(),
                        Examples = scenario.Examples.Select(ConvertExamples).ToReadOnlyCollection(),
                    }
                });

            case Ast.Rule rule:
            {
                return(new Children()
                    {
                        Rule = new Rule()
                        {
                            Name = rule.Name == string.Empty ? null : rule.Name,
                            Keyword = rule.Keyword,
                            Children = rule.Children.Select(ConvertToChildren).ToReadOnlyCollection(),
                            Location = ConvertLocation(rule.Location)
                        }
                    });
            }



            default:
                throw new NotImplementedException();
            }
        }
Exemple #8
0
        protected virtual ILocation GetLocation(UIElement element)
        {
            IHasLocation elementWithLocation = element as IHasLocation;
            ILocation    location;

            if (elementWithLocation != null)
            {
                location = elementWithLocation.Location;
            }
            else
            {
                location = GetLocationPropertyValueIfSet(element);
            }
            return(location);
        }
        static bool CanGenerate(IHasLocation x)
        {
            var patterns = new[] { BackgroundRegex, ScenarioRegex };

            bool IsMatch(string text) => patterns.Any(a => a.IsMatch(text));

            switch (x)
            {
            case Background background:
                return(IsMatch(background.Name ?? ""));

            case StepsContainer stepsContainer:
                return(stepsContainer.Steps.Any(step => IsMatch(step.Text ?? "")));

            default:
                return(false);
            }
        }
Exemple #10
0
        /// <summary>
        /// TODO: EXPERIEMTNAL.
        /// Everything will be wired up to events and state machines.
        /// </summary>
        /// <param name="aPlayer"></param>
        public virtual void Execute(Player aPlayer)
        {
            bool meleeRange = false;

            WayPoint = aPlayer;

            if (WayPoint == null)
                return;

            // TODO: factor this out.
            var nStack = Brain.PathFinding.Solve(this, WayPoint);

            // TODO: factor this out.
            if (nStack == null)
                return;

            if (_speedCounter % this.Stats.Speed == 0)
            {
                // when the player is in range, don't pop, flag as melee range.
                WayPoint = nStack.Pop();

                // dont allow this baddy to go *onto* the player.
                if (WayPoint.Location == GameEngine.Player.Location)
                {
                    // stay right here.
                    WayPoint.Location = Location;
                    meleeRange = true;
                }

                Location = WayPoint.Location;
                _speedCounter = 0;
            }

            if (meleeRange)
                new ActionMeleeAttack(this, aPlayer).Perform();

            _speedCounter++;
        }
Exemple #11
0
        private RuleChild ConvertToRuleChild(IHasLocation hasLocation)
        {
            var tuple = ConvertToChild(hasLocation);

            return(new RuleChild(tuple.Item1, tuple.Item3));
        }
Exemple #12
0
        private FeatureChild ConvertToFeatureChild(IHasLocation hasLocation)
        {
            var tuple = ConvertToChild(hasLocation);

            return(new FeatureChild(tuple.Item3, tuple.Item1, tuple.Item2));
        }
Exemple #13
0
        private void FormatHasLocation(IHasLocation hasLocation, StringBuilder result)
        {
            if (hasLocation == null || !IncludePositions)
                return;

            result.AppendFormat("({0}:{1})", hasLocation.Location.Line, hasLocation.Location.Column);
        }