Ejemplo n.º 1
0
        void ConfigureFinder()
        {
            //This is an example of a 'scene graph' query you can use in finder

            //Add some objects to the scene graph...
            _gameObjects.Add(new PlayerGameObject {
                Name = "Player 1", Health = 100
            });
            for (var i = 1; i <= 5; i++)
            {
                _gameObjects.Add(new EnemyGameObject {
                    Name = "Enemy " + i, Damage = i * 10
                });
            }

            //Set the Finder function to query the _gameObjects collection
            GS.GearsetComponent.Console.SetFinderSearchFunction(queryString =>
            {
                var result       = new FinderResult();
                var searchParams = queryString.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                // Split the query
                if (searchParams.Length == 0)
                {
                    searchParams = new[] { String.Empty };
                }
                else
                {
                    // Ignore case.
                    for (var i = 0; i < searchParams.Length; i++)
                    {
                        searchParams[i] = searchParams[i].ToUpper();
                    }
                }

                foreach (var component in _gameObjects)
                {
                    var matches = true;
                    var type    = component.GetType().ToString();

                    // Check if it matches all search params.
                    foreach (var t in searchParams)
                    {
                        if (component.ToString().ToUpper().Contains(t) || type.ToUpper().Contains(t))
                        {
                            continue;
                        }

                        matches = false;
                        break;
                    }

                    if (matches)
                    {
                        result.Add(new ObjectDescription(component, type));
                    }
                }
                return(result);
            });
        }
Ejemplo n.º 2
0
        //Finder

        public override void FinderSearch(FinderResult results)
        {
            if (_finderWindow == null)
            {
                return;
            }

            _finderWindow.ResultsListBox.ItemsSource = results;

            if (_finderWindow.ResultsListBox.Items.Count > 0)
            {
                _finderWindow.ResultsListBox.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The default search function. It will search through the GameComponentCollection of the Game.
        /// </summary>
        static FinderResult DefaultSearchFunction(String queryString)
        {
            var result       = new FinderResult();
            var searchParams = queryString.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            // Split the query
            if (searchParams.Length == 0)
            {
                searchParams = new [] { String.Empty };
            }
            else
            {
                // Ignore case.
                for (var i = 0; i < searchParams.Length; i++)
                {
                    searchParams[i] = searchParams[i].ToUpper();
                }
            }

            foreach (var component in GearsetResources.Game.Components)
            {
                var matches = true;
                var type    = component.GetType().ToString();

                if (component is GearsetComponentBase)
                {
                    continue;
                }

                // Check if it matches all search params.
                foreach (var t in searchParams)
                {
                    if (component.ToString().ToUpper().Contains(t) || type.ToUpper().Contains(t))
                    {
                        continue;
                    }

                    matches = false;
                    break;
                }

                if (matches)
                {
                    result.Add(new ObjectDescription(component, type));
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        //Finder
        public override void FinderSearch(FinderResult results)
        {
            if (CreateUI == false)
            {
                return;
            }

            var items = new FinderWindowViewModel.FinderResult();

            foreach (var result in results)
            {
                items.Add(new GearsetModelObjectDescription(result.Object, result.Description, result.Name));
            }

            _finderWindowViewModel.Items = items;

            if (_finderWindow.ResultsDataGrid.Items.Count > 0)
            {
                _finderWindow.ResultsDataGrid.SelectedIndex = 0;
            }
        }
Ejemplo n.º 5
0
 //Finder
 public abstract void FinderSearch(FinderResult results);
Ejemplo n.º 6
0
 //Finder
 public override void FinderSearch(FinderResult results)
 {
 }
Ejemplo n.º 7
0
        /// <summary>
        /// The default search function. It will search through the GameComponentCollection
        /// of the Game.
        /// </summary>
        private FinderResult DefaultSearchFunction(String queryString)
        {
            FinderResult result = new FinderResult();
            String[] searchParams = queryString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            // Split the query
            if (searchParams.Length == 0)
            {
                searchParams = new String[] { String.Empty };
            }
            else
            {
                // Ignore case.
                for (int i = 0; i < searchParams.Length; i++)
                    searchParams[i] = searchParams[i].ToUpper();
            }

            foreach (IGameComponent component in GearsetResources.Game.Components)
            {
                bool matches = true;
                String type = component.GetType().ToString();

                if (component is GearsetComponentBase)
                    continue;

                // Check if it matches all search params.
                for (int i = 0; i < searchParams.Length; i++)
                {
                    if (!(component.ToString().ToUpper().Contains(searchParams[i]) || type.ToUpper().Contains(searchParams[i])))
                    {
                        matches = false;
                        break;
                    }
                }
                if (matches)
                    result.Add(new ObjectDescription(component, type));
            }
            return result;
        }