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


C# LinkedList.Any方法代码示例

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


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

示例1: LinkedListExtensions_Any_ReturnsFalseIfLinkedListDoesNotContainItems

        public void LinkedListExtensions_Any_ReturnsFalseIfLinkedListDoesNotContainItems()
        {
            var list = new LinkedList<Int32>();

            var result = list.Any();

            TheResultingValue(result).ShouldBe(false);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:8,代码来源:LinkedListExtensionsTest.cs

示例2: LinkedListExtensions_Any_ReturnsTrueIfLinkedListContainsItems

        public void LinkedListExtensions_Any_ReturnsTrueIfLinkedListContainsItems()
        {
            var list = new LinkedList<Int32>();
            list.AddLast(1);

            var result = list.Any();

            TheResultingValue(result).ShouldBe(true);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:9,代码来源:LinkedListExtensionsTest.cs

示例3: LinkedListExtensions_AnyWithPredicate_ReturnsFalseIfLinkedListDoesNotContainMatchingItems

        public void LinkedListExtensions_AnyWithPredicate_ReturnsFalseIfLinkedListDoesNotContainMatchingItems()
        {
            var list = new LinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(3);

            var result = list.Any(x => x % 2 == 0);

            TheResultingValue(result).ShouldBe(false);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:10,代码来源:LinkedListExtensionsTest.cs

示例4: SelectATK

        public void SelectATK(BattlePhase _battlephase,Player _player, Computer _computer)
        {
            Card monsterbeATK;
            int minBattlePoint;
            Card monsteratk;
            if (_player.MonsterField.ListCard.Any())
            {
                // chọn trước lá bị tấn công
                minBattlePoint = _player.MonsterField.ListCard.Min(card => (card as Monster).BattlePoint);
                monsterbeATK = _player.MonsterField.ListCard.Where(card => (card as Monster).BattlePoint == minBattlePoint).First();
            }
            else
            {
                minBattlePoint = 0;
                monsterbeATK = null;
            }
            if (_battlephase.List_monsterATK.Any())
            {
                LinkedList<Card> list = new LinkedList<Card>(
                    _battlephase.List_monsterATK
                    .Where(card =>  (card as Monster).Atk > minBattlePoint));

                if (list.Any())
                {
                    monsteratk = list
                        .OrderBy(card => (card as Monster).Atk)
                        .First();
                }
                else
                    monsteratk = null;
            }
            else
            {
                monsteratk = null;
            }
            _battlephase.MonsterATK = monsteratk as Monster;
            if (_battlephase.MonsterATK != null)
                _battlephase.MonsterBeATK = monsterbeATK as Monster;
            else
                _battlephase.MonsterBeATK = null;
        }
开发者ID:luuthevinh,项目名称:yugioh-new-gen,代码行数:41,代码来源:YamiYugiDeck_AI.cs

示例5: Add

        private static LinkedListNode<WeekViewModel> Add(
            WeekViewModel model,
            LinkedList<WeekViewModel> models)
        {
            LinkedListNode<WeekViewModel> node;

            if (models.Any() == false)
            {
                node = models.AddFirst(model);
            }
            else if (model.Monday.Date < models.First.Value.Monday.Date)
            {
                node = models.AddFirst(model);
            }
            else// if (model.Monday.Date > models.Last.Value.Monday.Date)
            {
                node = models.AddLast(model);
            }

            return node;
        }
开发者ID:Stolpe,项目名称:KitsTajmMobile,代码行数:21,代码来源:WeekModelRepository.cs

示例6: _merge_prefix

        private void _merge_prefix(LinkedList<byte[]> deque, int size)
        {
            /*Replace the first entries in a deque of strings with a single
            string of up to size bytes.

            >>> d = collections.deque(['abc', 'de', 'fghi', 'j'])
            >>> _merge_prefix(d, 5); print d
            deque(['abcde', 'fghi', 'j'])

            Strings will be split as necessary to reach the desired size.
            >>> _merge_prefix(d, 7); print d
            deque(['abcdefg', 'hi', 'j'])

            >>> _merge_prefix(d, 3); print d
            deque(['abc', 'defg', 'hi', 'j'])

            >>> _merge_prefix(d, 100); print d
            deque(['abcdefghij'])
            */
            if (deque.Count == 1 && deque.at(0).Length <= size)
                return;
            var prefix = new List<byte[]>();
            var remaining = size;
            while (deque.Any() && remaining > 0)
            {
                var chunk = deque.popleft();
                if (chunk.Length > remaining)
                {
                    var segment = new ArraySegment<byte>(chunk, remaining, chunk.Length - remaining);
                   
                    deque.AddFirst(chunk.substr(remaining)); // deque.AddFirst(chunk[remaining:]);
                    chunk = chunk.substr(0, remaining); // chunk = chunk[:remaining];
                }
                prefix.Add(chunk);
                remaining -= chunk.Length;
            }
            // This data structure normally just contains byte strings, but
            // the unittest gets messy if it doesn't use the default str() type,
            // so do the merge based on the type of data that's actually present.
            if (prefix.Count > 0)
                deque.AddFirst(ByteArrayExtensions.join(prefix.ToArray()));
            if (deque.Count == 0)
                deque.AddFirst(new byte[] {});
        }
开发者ID:swax,项目名称:Tornado.Net,代码行数:44,代码来源:iostream.cs

示例7: GetPossibleSequenceMatches

        private IEnumerable<Ms2Match> GetPossibleSequenceMatches(int ms2ScanNumber)
        {
            var productSpec = _run.GetSpectrum(ms2ScanNumber) as ProductSpectrum;
            if (productSpec == null) return null;

            var isolationWindow = productSpec.IsolationWindow;
            var minMz = isolationWindow.MinMz;
            var maxMz = isolationWindow.MaxMz;

            var matchList = new List<Ms2Match>();
            var precursorSpec = _run.GetSpectrum(_run.GetPrecursorScanNum(ms2ScanNumber));
            if (precursorSpec != null)
            {
                var peakList = precursorSpec.GetPeakListWithin(minMz, maxMz);
                var peakListSortedByIntensity = new List<Peak>(peakList);
                peakListSortedByIntensity.Sort(new IntensityComparer());
                var remainingPeakList = new LinkedList<Peak>(peakListSortedByIntensity);
                while (remainingPeakList.Any())
                {
                    var peakMz = remainingPeakList.First.Value.Mz;
                    FindMatchedIons(peakMz, peakList, ref matchList);
                    remainingPeakList.RemoveFirst();
                }
            }

            var nextScanNum = _run.GetNextScanNum(ms2ScanNumber, 1);
            var nextSpec = _run.GetSpectrum(nextScanNum);
            if (nextSpec != null)
            {
                var peakList = nextSpec.GetPeakListWithin(minMz, maxMz);
                var peakListSortedByIntensity = new List<Peak>(peakList);
                peakListSortedByIntensity.Sort(new IntensityComparer());
                var remainingPeakList = new LinkedList<Peak>(peakListSortedByIntensity);
                while (remainingPeakList.Any())
                {
                    var peakMz = remainingPeakList.First.Value.Mz;
                    FindMatchedIons(peakMz, peakList, ref matchList);
                    remainingPeakList.RemoveFirst();
                }
            }
            return matchList;
        }
开发者ID:javamng,项目名称:GitHUB,代码行数:42,代码来源:Ms1BasedFilter.cs

示例8: Enumerate

		/// <summary>
		/// Enumerates all modules and submodules in BFS order.
		/// </summary>
		/// <param name="rootObj"></param>
		/// <returns></returns>
		internal static IEnumerable<ModuleBinding> Enumerate ( object rootObj )
		{
			var list = new List<ModuleBinding>();

			var queue = new LinkedList<ModuleBinding>();

			foreach ( var module in GetModuleBindings(rootObj).Reverse() ) {
				queue.AddFirst( module );
			}

			while (queue.Any()) {
				var module = queue.First();
				queue.RemoveFirst();

				list.Add(module);

				foreach ( var childModule in GetModuleBindings(module.Module) ) {
					queue.AddFirst( childModule );
				}
			}

			return list;
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:28,代码来源:GameModule.cs

示例9: DisplayLastActions

        private void DisplayLastActions(LinkedList<GameAction> actions)
        {
            const string displayLabel = "Actions";
            const int displayedActionsCount = 5;
            const int rowStart = 3;

            DisplayLabel(displayLabel, ActionsDistanceFromRight);

            if (actions.Any())
            {
                int row = rowStart;

                var action = actions.Last;
                for (int x = 0; x < displayedActionsCount; x++)
                {
                    if (action == null)
                        break;

                    string text = action.Value.ToString();
                    int startColumn = Console.WindowWidth - text.Length - ActionsDistanceFromRight;
                    Console.SetCursorPosition(startColumn, row);
                    Console.Write(text);

                    action = action.Previous;
                    row++;
                }
            }
        }
开发者ID:KallDrexx,项目名称:Twos,代码行数:28,代码来源:OutputProcessor.cs

示例10: SaveAsComponent

        //k - ���������� ����������� ��� ������������
        private void SaveAsComponent(ModelDoc2 swModel, Component2 inComp, bool isFirstLevel, LinkedList<CopiedFileNames> filesNames, int k)
        {
            string offset = string.Empty;
            //for (int i = 0; i < k; i++)
            //    offset += "   ";
            try
            {
                string strSubCompOldFileNameFromComponent = inComp.GetPathName();
                if (strSubCompOldFileNameFromComponent == "")
                {
                    var swCompModel = (ModelDoc2)inComp.GetModelDoc();
                    if (swCompModel != null)
                        strSubCompOldFileNameFromComponent = swCompModel.GetPathName();
                    else
                        return;
                }

                bool isModelAlreadyReplaced =
                    filesNames.Any(oldfile => oldfile.OldName == strSubCompOldFileNameFromComponent);

                if (!isModelAlreadyReplaced)
                {
                    ModelDoc2 swCompModel;
                    string strSubCompOldFileNameFromModel;
                    if (GetComponentModel(swModel, inComp, out swCompModel, out strSubCompOldFileNameFromModel))
                    {

                        bool isAuxiliary = (swCompModel.get_CustomInfo2("", "Auxiliary") == "Yes");
                        bool isAccessory = (swCompModel.get_CustomInfo2("", "Accessories") == "Yes");

                        string strSubCompNewFileName;
                        if (GetComponentNewFileName(swModel, isAuxiliary, isAccessory,
                                                    isFirstLevel, strSubCompOldFileNameFromModel,
                                                    out strSubCompNewFileName))
                        {

                            bool isCopyError = false;

                            try
                            {
                                if (!File.Exists(strSubCompNewFileName)) //���������
                                {
                                    File.Copy(strSubCompOldFileNameFromModel, strSubCompNewFileName, true);

                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show(@"�� ������� ��������� ���� " + strSubCompNewFileName,
                                                MyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                isCopyError = true;
                            }
                            if (!isCopyError)
                            {
                                filesNames.AddLast(new CopiedFileNames(strSubCompOldFileNameFromComponent,
                                                                       strSubCompNewFileName));
                                File.SetAttributes(strSubCompNewFileName, FileAttributes.Normal);

                                var subComps = new LinkedList<Component2>();
                                if (GetComponents(inComp, subComps, false, false))
                                {
                                    foreach (Component2 subcmp in subComps)
                                    {
                                        SaveAsComponent(swModel, subcmp, false, filesNames, k + 1);
                                    }

                                }

                                SwDmDocumentOpenError oe;

                                SwDMApplication swDocMgr = GetSwDmApp();
                                var swDoc = (SwDMDocument8)swDocMgr.GetDocument(strSubCompNewFileName,
                                                                                 SwDmDocumentType.swDmDocumentAssembly,
                                                                                 false, out oe);

                                if (swDoc != null)
                                {
                                    SwDMSearchOption src = swDocMgr.GetSearchOptionObject();
                                    src.SearchFilters = 255;

                                    object brokenRefVar;
                                    var varRef = (object[])swDoc.GetAllExternalReferences2(src, out brokenRefVar);

                                    if (varRef != null)
                                    {
                                        foreach (object t in varRef)
                                        {
                                            var strRef = (string)t;
                                            string strRefFileName = Path.GetFileName(strRef);
                                            string strNewRef = "";
                                            foreach (CopiedFileNames oldfile in filesNames)
                                            {
                                                if (Path.GetFileName(oldfile.OldName).ToLower() == strRefFileName.ToLower())
                                                {
                                                    strNewRef = oldfile.NewName;
                                                    break;
                                                }
                                            }
                                            if (strNewRef != "")
//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:SwAddin.cs

示例11: CheckSuffixModel

        private bool CheckSuffixModel(Component2 comp, string suffix, out bool notModel)
        {
            notModel = false;
            try
            {
                string tmp = Path.GetFileNameWithoutExtension(comp.GetPathName());
                if (tmp.Substring(tmp.Length - 4, 4)[0] == '#' && (tmp.Substring(tmp.Length - 4, 4)[3] == 'P' || tmp.Substring(tmp.Length - 4, 4)[3] == 'p'))
                {
                    return false;
                }
                var model = comp.IGetModelDoc();
                if (model != null)
                {
                    if (Properties.Settings.Default.CashModeOn && model.get_CustomInfo2("", "Accessories") == "Yes")
                        return false;
                    if (!Path.GetFileNameWithoutExtension(model.GetPathName()).Contains(suffix))
                    {
                        if (model.GetConfigurationCount() == 1 && model.get_CustomInfo2("", "Articul") != "")
                            return true;

                        var configNames = (string[])model.GetConfigurationNames();
                        if (configNames.Any(configName => model.get_CustomInfo2(configName, "Articul") != ""))
                            return true;

                        var outComps = new LinkedList<Component2>();
                        bool val;
                        if (GetComponents(comp, outComps, false, false) &&
                            outComps.Any(component2 => CheckSuffixModel(component2, suffix, out val)))
                            return true;
                    }
                    else
                    {
                        if (model.GetType() != (int)swDocumentTypes_e.swDocASSEMBLY)
                            return false;

                        var comps = (object[])((AssemblyDoc)model).GetComponents(false);
                        return
                            (from Component2 c in comps select Path.GetFileNameWithoutExtension(c.GetPathName())).
                                Any(
                                    name => !name.Contains(suffix));

                    }
                }
                else
                {
                    SwDmDocumentOpenError oe;

                    if (!Path.GetFileNameWithoutExtension(comp.GetPathName()).Contains(suffix))
                    {
                        SwDMApplication swDocMgr = GetSwDmApp();
                        var swDoc = (SwDMDocument)swDocMgr.GetDocument(comp.GetPathName(),
                                                                        SwDmDocumentType.swDmDocumentAssembly, true,
                                                                        out oe);
                        if (swDoc != null)
                        {
                            SwDmCustomInfoType swDm;
                            if (swDoc.ConfigurationManager.GetConfigurationCount() == 1)
                            {
                                var names = (string[])swDoc.GetCustomPropertyNames();
                                if (names.Contains("Articul") && swDoc.GetCustomProperty("Articul", out swDm) != "")
                                    return true;
                            }
                            else
                            {
                                var names = (string[])swDoc.ConfigurationManager.GetConfigurationNames();
                                if ((from name in names
                                     select (SwDMConfiguration)swDoc.ConfigurationManager.GetConfigurationByName(name)
                                         into conf
                                         let nms = (string[])conf.GetCustomPropertyNames()
                                         where nms.Contains("Articul") && conf.GetCustomProperty("Articul", out swDm) != ""
                                         select conf).Any())
                                    return true;
                            }
                        }
                        else
                        {
                            notModel = true;
                            return true;
                        }
                    }
                    else
                    {
                        var outList = new LinkedList<Component2>();
                        if (GetComponents(comp, outList, true, false))
                        {
                            return
                                (from Component2 c in outList select Path.GetFileNameWithoutExtension(c.GetPathName())).
                                    Any(
                                        name => !name.Contains(suffix));
                        }
                    }
                }
            }
            catch
            {
                notModel = true;
                return true;
            }
            return false;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:100,代码来源:SwAddin.cs

示例12: GetAllUniqueModels

        public bool GetAllUniqueModels(ModelDoc2 inModel, out LinkedList<ModelDoc2> outModels)
        {
            Configuration swConfig;
            var swComponents = new LinkedList<Component2>();
            bool ret = false;

            outModels = new LinkedList<ModelDoc2>();
            try
            {
                outModels.AddLast(inModel);
                swConfig = (Configuration)inModel.GetActiveConfiguration();

                if (swConfig != null)
                {
                    var swRootComponent = (Component2)swConfig.GetRootComponent();

                    if (GetComponents(swRootComponent, swComponents, true, false))
                    {
                        foreach (Component2 comp in swComponents)
                        {
                            var swCompModel = (ModelDoc2)comp.GetModelDoc();

                            if (swCompModel != null)
                            {
                                ModelDoc2 model = swCompModel;
                                bool isModelAlreadyAdded = outModels.Any(mdoc => mdoc.GetPathName() == model.GetPathName());

                                if (!isModelAlreadyAdded)
                                    outModels.AddLast(swCompModel);
                            }
                        }
                    }
                }
                ret = true;
            }
            catch { }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:38,代码来源:SwAddin.cs

示例13: CopyDrawings2

        public void CopyDrawings2(bool isSilent, bool askIfExist, string whereToSearchDirectory)
        {
            var allUniqueModels = new LinkedList<ModelDoc2>();
            const string strErrorNoCompSel = "�������� ���� �� ���� ���������!";
            try
            {
                var swModel = (ModelDoc2)_iSwApp.ActiveDoc;
                var swSelMgr = (SelectionMgr)swModel.SelectionManager;

                int selCnt = swSelMgr.GetSelectedObjectCount();

                if (selCnt < 1)
                {
                    MessageBox.Show(strErrorNoCompSel, MyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    for (int i = 1; i <= selCnt; i++)
                    {
                        if (swSelMgr.GetSelectedObjectType3(i, 0) == (int)swSelectType_e.swSelCOMPONENTS)
                        {
                            var swComp = (Component2)swSelMgr.GetSelectedObject6(i, 0);

                            if (swComp.Name.Split('/').Count() == 2)
                                GetComponentByName(swModel, swComp.Name.Split('/').First(), false, out swComp);

                            var swCompModel = (ModelDoc2)swComp.GetModelDoc();
                            if (swCompModel != null)
                            {
                                LinkedList<ModelDoc2> selCompModels;

                                if (GetAllUniqueModels(swCompModel, out selCompModels))
                                {
                                    foreach (ModelDoc2 selmdoc in selCompModels)
                                    {
                                        ModelDoc2 selmdoc1 = selmdoc;

                                        bool isModelAlreadyAdded = allUniqueModels.Any(allmdoc => allmdoc.GetPathName() == selmdoc1.GetPathName());

                                        if (!isModelAlreadyAdded)
                                        {
                                            allUniqueModels.AddLast(selmdoc);

                                        }
                                    }
                                }
                            }
                        }
                    }
                    int copiedDrwNum = 0;
                    string notHaveDrawing = "������� �� ������� ���:\n";
                    const string strHaveCopied = "������� �����������.";
                    bool isNotHaveDrawing = false;
                    foreach (ModelDoc2 mdoc in allUniqueModels)
                    {
                        if ((mdoc.GetType() == (int)swDocumentTypes_e.swDocPART) || (mdoc.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY))
                        {
                            if (mdoc.get_CustomInfo2("", "Required Draft") == "Yes")
                            {
                                if (CopyDrawing(mdoc, askIfExist, whereToSearchDirectory))
                                {
                                    copiedDrwNum++;
                                }
                                else
                                {
                                    notHaveDrawing += (Path.GetFileName(mdoc.GetPathName()) + "\n");
                                    isNotHaveDrawing = true;
                                }
                            }
                            else
                            {
                                if (mdoc.get_CustomInfo2("", "Required Draft") == "No") continue;
                                if (mdoc.get_CustomInfo2(mdoc.IGetActiveConfiguration().Name, "Required Draft") == "Yes")
                                {
                                    if (CopyDrawing(mdoc, askIfExist, whereToSearchDirectory))
                                    {
                                        copiedDrwNum++;
                                    }
                                    else
                                    {
                                        notHaveDrawing += (Path.GetFileName(mdoc.GetPathName()) + "\n");
                                        isNotHaveDrawing = true;
                                    }
                                }
                            }
                        }
                    }
                    if (!isSilent)
                    {
                        if (copiedDrwNum > 0)
                        {
                            if (isNotHaveDrawing)
                            {
                                MessageBox.Show(strHaveCopied + @"\n" + notHaveDrawing, MyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show(strHaveCopied, MyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:SwAddin.cs

示例14: Make

        public void Make( int Seed, String Filename )
        {
            System.Console.WriteLine( "Generating Map [{0}]", Filename );
              Random Gen = new Random( Seed );
              xml.Version = 1;
              xml.Date = DateTime.Now;
              xml.Generator = Generator.MAIDynamicChokepoint;
              xml.Seed = Seed;
              xml.LOS = LOS;
              xml.Start = new Coord( );
              xml.Start.X = Gen.Next( xml.Width );
              xml.Start.Y = Gen.Next( xml.Height );
              xml.Goal = new Coord( );
              xml.Goal.X = Gen.Next( xml.Width );
              xml.Goal.Y = Gen.Next( xml.Height );
              GenericGridWorldDynamicState DS = new GenericGridWorldDynamicState( );
              GenericGridWorldStaticState SS = new GenericGridWorldStaticState( xml.Height, xml.Width, DS );
              DS.AddWorldObject( new Unit( xml.Start.X, xml.Start.Y,
            xml.Height, xml.Width, xml.Goal.X, xml.Goal.Y, LOS, 0 ) );

              bool[][] tiles = new bool[xml.Height][];
              for ( int i = 0 ; i < xml.Height ; i++ ) {
            tiles[i] = new bool[xml.Width];
              }

              LinkedList<Point> ChokePoints = new LinkedList<Point>( );
              for ( int i = 0 ; i < NumChokepoints ; i++ ) {
            ChokePoints.AddFirst( new Point( Gen.Next( xml.Width ), Gen.Next( xml.Height ) ) );
              }

              for ( int Y = 0 ; Y < xml.Height ; Y++ ) {
            for ( int X = 0 ; X < xml.Width ; X++ ) {
              if ( ChokePoints.Any( cp => Distance.OctileDistance( cp.X, X, cp.Y, Y ) <= ChokepointRadius ) ) {
            SS.Tiles[Y][X] = new ChokeTile<GenericGridWorldStaticState,
              GenericGridWorldDynamicState>( X, Y, xml.Height, xml.Width );
            tiles[Y][X] = false;
              } else {
            SS.Tiles[Y][X] = new PassableTile<GenericGridWorldStaticState,
              GenericGridWorldDynamicState>( X, Y, xml.Height, xml.Width );
            tiles[Y][X] = false;
              }
            }
              }

              Point U = new Point( xml.Start.X, xml.Start.Y );
              foreach ( var From in ChokePoints ) {
            foreach ( var To in ChokePoints ) {
              DrawLine( From, To, xml, SS, U, tiles );
            }
              }

              xml.Tiles = GridWorldFormat.ToTileString( SS, DS );

              try {
            var sol = new AStar<
              GenericGridWorldStaticState, GenericGridWorldDynamicState>(
            new SingleUnitOctileDistanceHeuristic( ), true, null )
            .Compute( SS, SS.InitialDynamicState, new DestinationsReachedGoal( ),
            GridWorldOperator.Ops ).First( );
            System.Console.WriteLine( "\tMap Generated Solution Cost [{0}]", sol.Cost );
              } catch ( PathNotFoundException ) {
            System.Console.WriteLine( "\tMap Generation Failed [{0}]", Filename );
            throw new MapCreationFailed( );
              }

              LinkedList<Point> AgentsLocs = new LinkedList<Point>( ChokePoints.Take( NumAgents ) );
              LinkedList<Agent> Agents = new LinkedList<Agent>( );
              foreach ( Point Loc in AgentsLocs ) {
            Agents.AddFirst( new Agent( ) {
              Location = Loc, Dst = Loc, Start = Loc
            } );
              }

              LinkedList<Step> ChangeList = new LinkedList<Step>( );

              for ( int sN = 0 ; sN < NumSteps || !AllAtStart( Agents ) ; sN++ ) {
            Step step = new Step( );
            step.StepNum = sN;
            List<Coord> Changes = new List<Coord>( );
            if ( sN == 0 ) {
              foreach ( Agent Agent in Agents ) {
            ToogleCircle( tiles, Agent.Location, AgentRadius, Changes, xml.Width, xml.Height,
              Agent.Location, Agents, AgentRadius, false );
              }
            }

            foreach ( Agent Agent in Agents ) {
              if ( sN < NumSteps && sN != 0 && Agent.Location.Equals( Agent.Dst ) && ( Gen.NextDouble( ) < MoveRate  ) ) {
            var NotReserved = ChokePoints.Where( x => !Agents.Any( a => a.Dst.Equals( x ) ) );
            if ( NotReserved.Count( ) > 0 ) {
              Agent.Dst = NotReserved.Skip( Gen.Next( NotReserved.Count( ) ) ).First( );
            }
              } else if ( !( sN < NumSteps ) ) {
            Agent.Dst = Agent.Start;
              }
              if ( !Agent.Location.Equals( Agent.Dst ) ) {
            ToogleCircle( tiles, Agent.Location, AgentRadius, Changes, xml.Width, xml.Height,
              Agent.Location, Agents, AgentRadius, false );

            Agent.Location = NextAll( Agent.Location, xml.Width, xml.Height, Agent.Dst );
//.........这里部分代码省略.........
开发者ID:Mokon,项目名称:mai,代码行数:101,代码来源:ChokepointGridWorldMaker.cs

示例15: GetMaterialInfo

		private string GetMaterialInfo( CompassData compass ) {

			var strs = new LinkedList<string>();

			foreach ( var item in compass.GetItems ) {

				string itemName;

				if ( item.ItemID == 4 ) {
					itemName = Constants.GetMaterialName( item.Metadata );

				} else {
					var itemMaster = KCDatabase.Instance.MasterUseItems[item.Metadata];
					if ( itemMaster != null )
						itemName = itemMaster.Name;
					else
						itemName = "謎のアイテム";
				}

				strs.AddLast( itemName + " x " + item.Amount );
			}

			if ( !strs.Any() ) {
				return "(なし)";

			} else {
				return string.Join( ", ", strs );
			}
		}
开发者ID:silfumus,项目名称:ElectronicObserver,代码行数:29,代码来源:FormCompass.cs


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