System.Collections.Generic.List.Add(int)

Here are the examples of the csharp api System.Collections.Generic.List.Add(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6794 Examples 7

19 View Source File : StringMap.cs
License : MIT License
Project Creator : 0x0ade

public void Cleanup() {
            lock (Pending) {
                foreach (KeyValuePair<string, int> entry in Counting) {
                    int score = entry.Value - DemotionScore;
                    if (score <= 0) {
                        CountingUpdateKeys.Add(entry.Key);
                        CountingUpdateValues.Add(0);
                    } else if (score >= PromotionTreshold) {
                        CountingUpdateKeys.Add(entry.Key);
                        CountingUpdateValues.Add(0);
                        Pending.Add(entry.Key);
                    } else {
                        CountingUpdateKeys.Add(entry.Key);
                        CountingUpdateValues.Add(score);
                    }
                }
                for (int i = 0; i < CountingUpdateKeys.Count; i++) {
                    string key = CountingUpdateKeys[i];
                    int value = CountingUpdateValues[i];
                    if (value == 0)
                        Counting.Remove(key);
                    else
                        Counting[key] = value;
                }
                CountingUpdateKeys.Clear();
                CountingUpdateValues.Clear();
            }
        }

19 View Source File : MaybeExTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        [TestCase(true)]
        [TestCase(false)]
        public async Task Main(bool async)
        {
            string[] inputs = { null, " 7 , 3", "100", "11,14", "8,a" };
            int?[] expected = {null, 10, null, 25, null};

            var acc = new List<int?>();
            foreach (var input in inputs)
            {
                MockDisposable.DisposingCounter = 0;
                var res = await GetResult(input, async).GetMaybeResult();
                acc.Add(res.IsNothing ? (int?)null : res.GetValue());
                replacedert.AreEqual(1, MockDisposable.DisposingCounter);
            }
            Collectionreplacedert.AreEqual(expected, acc);
        }

19 View Source File : MaybeTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        [TestCase(true)]
        [TestCase(false)]
        public async Task Main(bool async)
        {
            string[] inputs = { null, " 7 , 3", "100", "11,14", "8,a" };
            int?[] expected = {null, 10, null, 25, null};

            var acc = new List<int?>();
            foreach (var input in inputs)
            {
                var res = await GetResult(input, async).GetMaybeResult();
                acc.Add(res.IsNothing ? (int?)null : res.GetValue());
            }
            Collectionreplacedert.AreEqual(expected, acc);
        }

19 View Source File : HeifEncoderParameterFactory.cs
License : GNU Lesser General Public License v3.0
Project Creator : 0xC0000054

private static unsafe HeifIntegerEncoderParameter CreateIntegerParameter(SafeHeifEncoder encoder,
                                                                                 heif_encoder_parameter nativeParameter,
                                                                                 string name,
                                                                                 bool hasDefaultValue)
        {
            int defaultValue = 0;

            if (hasDefaultValue)
            {
                // The error value is ignored because some encoders return an error
                // when getting the value of a valid command.
                _ = LibHeifNative.heif_encoder_get_parameter_integer(encoder, name, out defaultValue);
            }

            bool haveMinimumMaximum;
            int minimum = 0;
            int maximum = 0;
            var validValues = new List<int>();

            if (LibHeifVersion.Is1Point10OrLater)
            {
                var error = LibHeifNative.heif_encoder_parameter_get_valid_integer_values(nativeParameter,
                                                                                          out bool haveMinimum,
                                                                                          out bool haveMaximum,
                                                                                          ref minimum,
                                                                                          ref maximum,
                                                                                          out int numValidValues,
                                                                                          out var validValuesArray);
                error.ThrowIfError();

                haveMinimumMaximum = haveMinimum && haveMaximum;

                if (numValidValues > 0 && validValuesArray != IntPtr.Zero)
                {
                    validValues.Capacity = numValidValues;

                    int* integerArray = (int*)validValuesArray;

                    for (int i = 0; i < numValidValues; i++)
                    {
                        validValues.Add(integerArray[i]);
                    }
                }
            }
            else
            {
                var error = LibHeifNative.heif_encoder_parameter_get_valid_integer_range(nativeParameter,
                                                                                         out haveMinimumMaximum,
                                                                                         ref minimum,
                                                                                         ref maximum);
                error.ThrowIfError();
            }

            return new HeifIntegerEncoderParameter(name,
                                                   hasDefaultValue,
                                                   defaultValue,
                                                   haveMinimumMaximum,
                                                   minimum,
                                                   maximum,
                                                   validValues.AsReadOnly());
        }

19 View Source File : AvifWriter.AvifWriterState.cs
License : MIT License
Project Creator : 0xC0000054

private void Initialize(IReadOnlyList<CompressedAV1Image> colorImages,
                                    IReadOnlyList<CompressedAV1Image> alphaImages,
                                    bool premultipliedAlpha,
                                    ImageGridMetadata imageGridMetadata,
                                    AvifMetadata metadata,
                                    IArrayPoolService arrayPool)
            {
                ImageStateInfo result;

                if (imageGridMetadata != null)
                {
                    result = InitializeFromImageGrid(colorImages, alphaImages, premultipliedAlpha, imageGridMetadata);
                    this.ItemDataBox = CreateItemDataBox(imageGridMetadata, arrayPool);
                }
                else
                {
                    result = InitializeFromSingleImage(colorImages[0], alphaImages?[0], premultipliedAlpha);
                    this.ItemDataBox = null;
                }

                uint itemId = result.NextId;
                ulong mediaDataBoxContentSize = result.MediaDataBoxContentSize;

                List<int> mediaDataBoxMetadataItemIndexes = new List<int>(2);

                byte[] exif = metadata.GetExifBytesReadOnly();
                if (exif != null && exif.Length > 0)
                {
                    AvifWriterItem exifItem = AvifWriterItem.CreateFromExif(itemId, exif);
                    itemId++;
                    exifItem.ItemReferences.Add(new ItemReferenceEntryBox(exifItem.Id, ReferenceTypes.ContentDescription, this.PrimaryItemId));

                    mediaDataBoxMetadataItemIndexes.Add(this.items.Count);
                    this.items.Add(exifItem);
                    mediaDataBoxContentSize += (ulong)exifItem.ContentBytes.Length;
                }

                byte[] xmp = metadata.GetXmpBytesReadOnly();
                if (xmp != null && xmp.Length > 0)
                {
                    AvifWriterItem xmpItem = AvifWriterItem.CreateFromXmp(itemId, xmp);
                    xmpItem.ItemReferences.Add(new ItemReferenceEntryBox(xmpItem.Id, ReferenceTypes.ContentDescription, this.PrimaryItemId));

                    mediaDataBoxMetadataItemIndexes.Add(this.items.Count);
                    this.items.Add(xmpItem);
                    mediaDataBoxContentSize += (ulong)xmpItem.ContentBytes.Length;
                }

                this.MediaDataBoxContentSize = mediaDataBoxContentSize;
                this.MediaDataBoxMetadataItemIndexes = mediaDataBoxMetadataItemIndexes;
            }

19 View Source File : AvifWriter.AvifWriterState.cs
License : MIT License
Project Creator : 0xC0000054

private ImageStateInfo InitializeFromImageGrid(IReadOnlyList<CompressedAV1Image> colorImages,
                                                           IReadOnlyList<CompressedAV1Image> alphaImages,
                                                           bool premultipliedAlpha,
                                                           ImageGridMetadata imageGridMetadata)
            {
                ulong mediaDataBoxContentSize = 0;
                uint itemId = FirsreplacedemId;

                List<uint> colorImageIds = new List<uint>(colorImages.Count);
                List<uint> alphaImageIds = alphaImages != null ? new List<uint>(alphaImages.Count) : null;

                List<int> mediaDataBoxColorItemIndexes = new List<int>(colorImages.Count);
                List<int> mediaBoxAlphaItemIndexes = new List<int>(alphaImages != null ? alphaImages.Count : 0);

                for (int i = 0; i < colorImages.Count; i++)
                {
                    int duplicateImageIndex;
                    int duplicateColorImageIndex = -1;

                    if (this.duplicateColorTiles.TryGetValue(i, out duplicateImageIndex))
                    {
                        duplicateColorImageIndex = mediaDataBoxColorItemIndexes[duplicateImageIndex];
                    }

                    CompressedAV1Image color = colorImages[i];
                    AvifWriterItem colorItem = AvifWriterItem.CreateFromImage(itemId, null, color, false, duplicateColorImageIndex);
                    itemId++;
                    colorImageIds.Add(colorItem.Id);

                    mediaDataBoxColorItemIndexes.Add(this.items.Count);
                    this.items.Add(colorItem);

                    if (duplicateColorImageIndex == -1)
                    {
                        mediaDataBoxContentSize += color.Data.ByteLength;
                    }

                    if (alphaImages != null)
                    {
                        int duplicateAlphaImageIndex = -1;

                        if (this.duplicateAlphaTiles.TryGetValue(i, out duplicateImageIndex))
                        {
                            duplicateAlphaImageIndex = mediaBoxAlphaItemIndexes[duplicateImageIndex];
                        }

                        CompressedAV1Image alpha = alphaImages[i];
                        AvifWriterItem alphaItem = AvifWriterItem.CreateFromImage(itemId, null, alpha, true, duplicateAlphaImageIndex);
                        itemId++;
                        alphaItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaItem.Id, ReferenceTypes.AuxiliaryImage, colorItem.Id));

                        if (premultipliedAlpha)
                        {
                            alphaItem.ItemReferences.Add(new ItemReferenceEntryBox(colorItem.Id,
                                                                                   ReferenceTypes.PremultipliedAlphaImage,
                                                                                   alphaItem.Id));
                        }

                        alphaImageIds.Add(alphaItem.Id);
                        mediaBoxAlphaItemIndexes.Add(this.items.Count);
                        this.items.Add(alphaItem);

                        if (duplicateAlphaImageIndex == -1)
                        {
                            mediaDataBoxContentSize += alpha.Data.ByteLength;
                        }
                    }
                }

                ulong gridDescriptorLength;

                if (imageGridMetadata.OutputHeight > ushort.MaxValue || imageGridMetadata.OutputWidth > ushort.MaxValue)
                {
                    gridDescriptorLength = ImageGridDescriptor.LargeDescriptorLength;
                }
                else
                {
                    gridDescriptorLength = ImageGridDescriptor.SmallDescriptorLength;
                }

                // The grid items do not have any data to write in the media data box.
                AvifWriterItem colorGridItem = AvifWriterItem.CreateFromImageGrid(itemId, "Color", 0, gridDescriptorLength);
                itemId++;
                colorGridItem.ItemReferences.Add(new ItemReferenceEntryBox(colorGridItem.Id, ReferenceTypes.DerivedImage, colorImageIds));

                this.PrimaryItemId = colorGridItem.Id;
                this.items.Add(colorGridItem);

                if (alphaImages != null)
                {
                    // The ImageGridDescriptor is shared between the color and alpha image.
                    AvifWriterItem alphaGridItem = AvifWriterItem.CreateFromImageGrid(itemId, "Alpha", 0, gridDescriptorLength);
                    itemId++;
                    alphaGridItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaGridItem.Id, ReferenceTypes.AuxiliaryImage, colorGridItem.Id));
                    alphaGridItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaGridItem.Id, ReferenceTypes.DerivedImage, alphaImageIds));

                    if (premultipliedAlpha)
                    {
                        alphaGridItem.ItemReferences.Add(new ItemReferenceEntryBox(colorGridItem.Id,
                                                                                   ReferenceTypes.PremultipliedAlphaImage,
                                                                                   alphaGridItem.Id));
                    }

                    this.AlphaItemId = alphaGridItem.Id;
                    this.items.Add(alphaGridItem);
                }

                this.MediaDataBoxAlphaItemIndexes = mediaBoxAlphaItemIndexes;
                this.MediaDataBoxColorItemIndexes = mediaDataBoxColorItemIndexes;

                return new ImageStateInfo(mediaDataBoxContentSize, itemId);
            }

19 View Source File : AvifWriter.AvifWriterState.cs
License : MIT License
Project Creator : 0xC0000054

private ImageStateInfo InitializeFromSingleImage(CompressedAV1Image color, CompressedAV1Image alpha, bool premultipliedAlpha)
            {
                ulong mediaDataBoxContentSize = color.Data.ByteLength;
                uint itemId = FirsreplacedemId;

                List<int> mediaDataBoxColorItemIndexes = new List<int>(1);
                List<int> mediaBoxAlphaItemIndexes = new List<int>(1);

                AvifWriterItem colorItem = AvifWriterItem.CreateFromImage(itemId, "Color", color, false, duplicateImageIndex: -1);
                itemId++;
                this.PrimaryItemId = colorItem.Id;
                mediaDataBoxColorItemIndexes.Add(this.items.Count);
                this.items.Add(colorItem);

                if (alpha != null)
                {
                    AvifWriterItem alphaItem = AvifWriterItem.CreateFromImage(itemId, "Alpha", alpha, true, duplicateImageIndex: -1);
                    itemId++;
                    alphaItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaItem.Id, ReferenceTypes.AuxiliaryImage, this.PrimaryItemId));
                    if (premultipliedAlpha)
                    {
                        alphaItem.ItemReferences.Add(new ItemReferenceEntryBox(this.PrimaryItemId,
                                                                               ReferenceTypes.PremultipliedAlphaImage,
                                                                               alphaItem.Id));
                    }

                    this.AlphaItemId = alphaItem.Id;

                    mediaBoxAlphaItemIndexes.Add(this.items.Count);
                    this.items.Add(alphaItem);
                    mediaDataBoxContentSize += alpha.Data.ByteLength;
                }

                this.MediaDataBoxAlphaItemIndexes = mediaBoxAlphaItemIndexes;
                this.MediaDataBoxColorItemIndexes = mediaDataBoxColorItemIndexes;

                return new ImageStateInfo(mediaDataBoxContentSize, itemId);
            }

19 View Source File : Formatter.Array1.List.cs
License : MIT License
Project Creator : 1996v

public List<Int32> Deserialize(ref BssomReader reader, ref BssomDeserializeContext context)
        {
            if (reader.TryReadNullWithEnsureArray1BuildInType(BssomType.Int32Code))
            {
                return default;
            }

            context.Option.Security.DepthStep(ref context);
            reader.SkipVariableNumber();
            int len = reader.ReadVariableNumber();
            List<int> val = new List<Int32>(len);
            for (int i = 0; i < len; i++)
            {
                val.Add(reader.ReadInt32WithOutTypeHead());
            }
            context.Depth--;
            return val;
        }

19 View Source File : ServerLoop.cs
License : MIT License
Project Creator : 1ZouLTReX1

public void Update(List<Player> players)
    {
        /*
        Update Clients and Apply User Commands
        Tick length is Time.fixedDeltaTime

        Remove used player's User Commands
        
        Take A Snapshot of the updated world
        */
        NetworkTick.tickSeq++;

        rayStates.Clear();

        tickDuration = Time.deltaTime;
        
        float startTickTime = StopWacthTime.Time;
        float endTickTime = startTickTime + tickDuration;

        // Important debug
        //Debug.Log("Tick Rate: " + (1.0f / tickDuration) + " [Hz], Tick Duration: " + (tickDuration * 1000) + "[ms]");
        //Debug.Log("Tick Duration " + tickDuration + " Start: " + startTickTime + " End: " + endTickTime);
        //Debug.Log("Tick delta " + (Mathf.RoundToInt((startTickTime - lastStartTickTime) / 0.00001f) * 0.00001)); // Drift;

        float simTimeForCurrTick = 0;
        float minorJump;

        float currEventsTime;
        float nextEventsTime;

        List<ServerUserCommand> currUserCommands;
        List<int> playerEventIndexes = new List<int>();

        for (int i = players.Count - 1; i >= 0; i--)
        {
            Player p = players[i];
            if (p.playerContainer != null)
            {
                // Before we run the tick we store the last tick in the backtracking buffer
                // Which is then beign used in the lag compensation algorithm.
                // This snapshot is being taken before the start of the tick therefore we subtract one
                p.playerContainer.GetComponent<LagCompensationModule>().TakeSnapshot(NetworkTick.tickSeq - 1);

                playerEventIndexes.Add(0);

                if (p != null)
                {
                    p.MergeWithBuffer();
                }
            }
            else
            {
                players.Remove(p);
            }
        }

        // Simulate Till first event
        // or Till the end Tick Time if there is no event from the clients.
        currEventsTime = GetEventsMinimalTime(players, playerEventIndexes);
        if (currEventsTime == NoMoreEvents)
            minorJump = tickDuration;
        else
            minorJump = (currEventsTime - startTickTime);

        if (minorJump > 0)
        {
            // DEBUG
            simTimeForCurrTick += minorJump;
            Physics2D.Simulate(minorJump);
        }
        else
        {
            minorJump = 0;
        }

        while (simTimeForCurrTick < tickDuration)
        {
            // Get all the events with minimal time.
            currUserCommands = GetEvents(players, playerEventIndexes, currEventsTime);

            nextEventsTime = GetEventsMinimalTime(players, playerEventIndexes);

            // START DEBUGGING
            // TODO MUST DEBUG HERE 
            /*
            if (currEventsTime == nextEventsTime)
            {
                nextEventsTime = NoMoreEvents;
            }

            if (currUserCommands.Count == 0)
            {
                nextEventsTime = NoMoreEvents;
            }
            */
            if (nextEventsTime == NoMoreEvents)
            {
                minorJump = tickDuration - simTimeForCurrTick;
            }
            else
            {
                minorJump = nextEventsTime - currEventsTime;
            }

            // END DEBUGGING

            if ((simTimeForCurrTick + minorJump) > tickDuration)
            {
                minorJump = tickDuration - simTimeForCurrTick;
            } 

            currEventsTime = nextEventsTime;

            ApplyUserCommands(currUserCommands);

            // DEBUG
            //Debug.Log("Minor Jump " + minorJump);

            simTimeForCurrTick += minorJump;
            Physics2D.Simulate(minorJump);
        }

        DeleteUsedEvents(players, playerEventIndexes);

        TakeSnapshot(players, rayStates);

        lastStartTickTime = startTickTime;

        // DEBUG the event loop, make sure we are simulating the same amount of time that preplaced in realtime
        // Debug.Log("Sim Time for tick: " + NetworkTick.tickSeq + ", " + simTimeForCurrTick + ", delta: " + (simTimeForCurrTick - tickDuration));
    }

19 View Source File : Form1.cs
License : MIT License
Project Creator : 20chan

private void TryEnqueue(int key) {
            var isChar = 65 <= key && key <= 90;
            if (!isChar) {
                queue.Clear();
                return;
            }
            queue.Add(key);
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public static List<int> GetTipList(List<int> _shoupai, List<int> _lastPaiArr)
        {
            //剩余牌的数量小于  只能用炸了  //等于上手出牌的数量     //剩余牌的数量大于上手出牌的数量
            List<int> _tiplist = new List<int>();
            LordPokerSplitHelper _splitHelper = new LordPokerSplitHelper();
            _splitHelper.Split(_shoupai);
            if (_lastPaiArr.Count == 0)
            {//没有上家牌,直接按AI规则出牌
                //最大牌型,考虑春天 再最多牌数
                if (_splitHelper._straight.Count != 0)
                {
                    _tiplist = _splitHelper._straight[0];
                }
                else if (_splitHelper._linkerPair.Count != 0)
                {
                    _tiplist = _splitHelper._linkerPair[0];
                    if (_tiplist.Count != 0) _tiplist.AddRange(_tiplist);
                }
                else if (_splitHelper._planeWith.Count != 0)
                {
                    List<int> _planeList = _splitHelper._planeWith[0];
                    List<int> _existoneList = new List<int>();
                    foreach (int _plane in _planeList)
                    {
                        _tiplist.Add(_plane);
                        _tiplist.Add(_plane);
                        _tiplist.Add(_plane);
                        int _tempwithone = _splitHelper.GetSingleToPlaneWith(_planeList, _existoneList);
                        if (_tempwithone != -1)
                        {
                            _tiplist.Add(_tempwithone);
                            _existoneList.Add(_tempwithone);
                        }
                    }
                    if (_tiplist.Count != _planeList.Count * 4) _tiplist = new List<int>();//重置========可能会出现全三带没的带的情况而可以把3张拆成
                }
                else if (_splitHelper._double.Count != 0)
                {
                    int _double = _splitHelper._double[_splitHelper._double.Count - 1];
                    _tiplist.Add(_double);
                    _tiplist.Add(_double);
                }
                ////else if (_splitHelper._bomb22.Count != 0)
                ////{
                ////    _tiplist.Add(_splitHelper._bomb22[0]);
                ////    _tiplist.Add(_splitHelper._bomb22[0]);
                ////}
                ////else if (_splitHelper._bomb33.Count != 0)
                ////{
                ////    _tiplist.Add(_splitHelper._bomb33[0]);
                ////    _tiplist.Add(_splitHelper._bomb33[0]);
                ////}
                else if (_splitHelper._bomb4List.Count != 0)
                {
                    int _bomb = _splitHelper._bomb4List[_splitHelper._bomb4List.Count - 1];
                    _tiplist.Add(_bomb);
                    _tiplist.Add(_bomb);
                    _tiplist.Add(_bomb);
                    _tiplist.Add(_bomb);
                }
                else if (_splitHelper._doubleKing.Count != 0)
                {
                    _tiplist.AddRange(_splitHelper._doubleKing);
                }
                else
                {
                    _tiplist.Add(_splitHelper._single[_splitHelper._single.Count - 1]);
                }
                _tiplist = GetPaiColor(_shoupai, _tiplist);
                return _tiplist;
            }
            List<int> _templastPoker = OrderPaiLord(_lastPaiArr);
            LordPokerTypeEnum _lordtype = GetLordType(_templastPoker);
            switch (_lordtype)
            {
                case LordPokerTypeEnum.DoubleKing_2: return new List<int>();//如果上手出了王炸,直接要不起 
                case LordPokerTypeEnum.Bomb_4:
                    _tiplist = UseBomb(_splitHelper, _templastPoker[0]);
                    if (_tiplist.Count != 0) _tiplist = GetPaiColor(_shoupai, _tiplist);
                    return _tiplist;

                case LordPokerTypeEnum.Single_1:// 单张           
                    _tiplist = GetSingleBig(_templastPoker, _splitHelper);
                    break;
                case LordPokerTypeEnum.Double_2:
                    _tiplist = GetDoubleBig(_templastPoker, _splitHelper);
                    break;
                case LordPokerTypeEnum.Three_3:
                    _tiplist = GetThreeBig(_templastPoker, _splitHelper);
                    break;
                case LordPokerTypeEnum.PlaneWing1_4:
                case LordPokerTypeEnum.PlaneWing2_8:
                case LordPokerTypeEnum.PlaneWing3_12:
                case LordPokerTypeEnum.PlaneWing4_16:
                case LordPokerTypeEnum.PlaneWing5_20:
                    _tiplist = GetPlaneBig(_templastPoker, _splitHelper);
                    break;
                case LordPokerTypeEnum.Straight5_5:
                case LordPokerTypeEnum.Straight6_6:
                case LordPokerTypeEnum.Straight7_7:
                case LordPokerTypeEnum.Straight8_8:
                case LordPokerTypeEnum.Straight9_9:
                case LordPokerTypeEnum.Straight10_10:
                case LordPokerTypeEnum.Straight11_11:
                case LordPokerTypeEnum.Straight12_12:
                    _tiplist = GetStraightBig(_templastPoker, _splitHelper);
                    break;
                case LordPokerTypeEnum.LinkPair3_6:
                case LordPokerTypeEnum.LinkPair4_8:
                case LordPokerTypeEnum.LinkPair5_10:
                case LordPokerTypeEnum.LinkPair6_12:
                case LordPokerTypeEnum.LinkPair7_14:
                case LordPokerTypeEnum.LinkPair8_16:
                case LordPokerTypeEnum.LinkPair9_18:
                case LordPokerTypeEnum.LinkPair10_20:
                    _tiplist = GetLinkerPairBig(_templastPoker, _splitHelper);
                    break;
                case LordPokerTypeEnum.FourWithTwo_6:
                    _tiplist = GetFourWithTwoBig(_templastPoker, _splitHelper);
                    break;
                default:
                    TraceLogEx.Error(_lordtype + ":...............................lllllllllllllllllllllll");
                    break;
            }

            if (_tiplist.Count == 0)
            {
                _tiplist = UseBomb(_splitHelper, 0);
            }
            if (_tiplist.Count != 0) _tiplist = GetPaiColor(_shoupai, _tiplist);
            return _tiplist;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetDoubleBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _ret = new List<int>();
            if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;

            for (int i = _splitHelper._double.Count - 1; i >= 0; i--)
            {
                if (_splitHelper._double[i] > _lastPoker[0])
                {
                    _ret.Add(_splitHelper._double[i]);
                    _ret.Add(_splitHelper._double[i]);
                    break;
                }
            }
            return _ret;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetPlaneBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _lastThreeList = GetSameMoreThan3(_lastPoker);
            if (_lastPoker.Count == 4)
            {
                List<int> _ret = new List<int>();
                if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
                if (_splitHelper._three.Count < 1) return _ret;
                for (int i = _splitHelper._three.Count - 1; i >= 0; i--)
                {
                    if (_splitHelper._three[i] > _lastThreeList[0])
                    {
                        _ret.Add(_splitHelper._three[i]);
                        _ret.Add(_splitHelper._three[i]);
                        _ret.Add(_splitHelper._three[i]);
                        int _tempwithone = _splitHelper.GetSingleToPlaneWith(new List<int>() { _splitHelper._three[i] });
                        if (_tempwithone != -1) _ret.Add(_tempwithone);
                        break;
                    }
                }
                if (_ret.Count == 4) return _ret;
                return new List<int>();
            }
            else
            {
                List<int> _tiplist = new List<int>();
                if (_splitHelper._planeWith.Count < 1) return _tiplist;
                foreach (List<int> _planeList in _splitHelper._planeWith)
                {
                    if (_planeList.Count < _lastThreeList.Count) continue;//个数不够
                    if (_planeList[0] < _lastThreeList[0]) continue;//大小不对 ==================需要写在从最小值取值 ,现在直接从最大值开取的=======
                    foreach (int _plane in _planeList)
                    {
                        _tiplist.Add(_plane);
                        _tiplist.Add(_plane);
                        _tiplist.Add(_plane);
                        int _tempwithone = _splitHelper.GetSingleToPlaneWith(_planeList);
                        if (_tempwithone != -1) _tiplist.Add(_tempwithone);
                    }
                    if (_tiplist.Count != _planeList.Count * 4) _tiplist = new List<int>();//重置========可能会出现全三带没的带的情况而可以把3张拆成
                }
                return _tiplist;
            }
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetFourWithTwoBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _lastThreeList = GetSameMoreThan3(_lastPoker);
            List<int> _ret = new List<int>();
            if (_lastPoker.Count != 6) return _ret;
            if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
            if (_splitHelper._four.Count < 1) return _ret;

            for (int i = _splitHelper._four.Count - 1; i >= 0; i--)
            {
                if (_splitHelper._four[i] > _lastThreeList[0])
                {
                    _ret.Add(_splitHelper._four[i]);
                    _ret.Add(_splitHelper._four[i]);
                    _ret.Add(_splitHelper._four[i]);
                    _ret.Add(_splitHelper._four[i]);
                    List<int> _tempwithone = _splitHelper.GetSingleToFourWith(new List<int>() { _splitHelper._four[i] });
                    _ret.AddRange(_tempwithone);
                    break;
                }
            }
            if (_ret.Count == 6) return _ret;
            return new List<int>();

        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public void SearchBase()
        {
            Dictionary<int, int> _dicPoker2Count = LandLord.GetPoker_Count(_shouPai);
            List<int> _temp = new List<int>();
            foreach (int key in _dicPoker2Count.Keys)
            {
                if (_dicPoker2Count[key] == 4)
                {
                    _one.Add(key);
                    _two.Add(key);
                    _three.Add(key);
                    _four.Add(key);
                }
                else if (_dicPoker2Count[key] == 3)
                {
                    _one.Add(key);
                    _two.Add(key);
                    _three.Add(key);
                }
                else if (_dicPoker2Count[key] == 2)
                {
                    _one.Add(key);
                    _two.Add(key);
                }
                else if (_dicPoker2Count[key] == 1) _one.Add(key);
            }
            _one = LandLord.OrderPaiLord(_one);
            _two = LandLord.OrderPaiLord(_two);
            _three = LandLord.OrderPaiLord(_three);
            _four = LandLord.OrderPaiLord(_four);
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public void SearchBomb()
        {
            ////if (_two.Contains((int)LordPokerValueNoColorEnum.p3)) _bomb33.Add((int)LordPokerValueNoColorEnum.p3);
            ////if (_two.Contains((int)LordPokerValueNoColorEnum.p15)) _bomb22.Add((int)LordPokerValueNoColorEnum.p15);
            if (_one.Contains((int)LordPokerValueNoColorEnum.jokers16) && _one.Contains((int)LordPokerValueNoColorEnum.jokersb17))
            {
                _doubleKing.Add((int)LordPokerValueNoColorEnum.jokers16);
                _doubleKing.Add((int)LordPokerValueNoColorEnum.jokersb17);
            }
            _bomb4List = new List<int>(_four);
        }

19 View Source File : YmlFormatUtil.cs
License : Apache License 2.0
Project Creator : 214175590

public static List<YmlLine> FormatYml(string content, bool beautify = false)
        {
            List<YmlLine> list = new List<YmlLine>();
            string[] lines = content.Split('\n');
            YmlLine ylText = null;
            int index1 = -1, index2 = -1, count = 0, num = 0;
            string startStr = null, endStr = null, line = "";
            string key = null, value = null, mh = ":";
            List<int> levels = new List<int>();
            for(int i = 0, k = lines.Length; i < k; i++){
                line = lines[i];

                if(line.TrimStart().StartsWith("#")){
                    ylText = new YmlLine()
                    {
                        Text = line + "\n",
                        Color = Color.Gray
                    };
                    list.Add(ylText);
                }
                else
                {
                    // 非整行注释

                    // 美化
                    if (beautify)
                    {
                        count = StartSpaceCount(line);
                        if (count == 0)
                        {
                            levels.Clear();
                        }
                        // level
                        if (!levels.Contains(count))
                        {
                            levels.Add(count);
                            levels.Sort();
                        }
                        num = levels.IndexOf(count) * 4;
                        if (num > count)
                        {
                            line = GetSpace(num - count) + line;
                        }
                    }                    

                    // 行中有井号,但不是首位#
                    index2 = line.IndexOf("#");
                    if(index2 > 0){
                        startStr = line.Substring(0, index2);

                        index1 = startStr.IndexOf(":");
                        if (index1 > 0)
                        {
                            // key
                            key = startStr.Substring(0, index1);
                            ylText = new YmlLine()
                            {
                                Text = key,
                                Color = Color.OrangeRed
                            };
                            list.Add(ylText);
                            // :
                            ylText = new YmlLine()
                            {
                                Text = mh,
                                Color = Color.Violet
                            };
                            list.Add(ylText);
                            // value
                            value = startStr.Substring(index1 + 1);
                            ylText = new YmlLine()
                            {
                                Text = value,
                                Color = getTextColor(value)
                            };
                            list.Add(ylText);
                        }
                        else
                        {
                            ylText = new YmlLine()
                            {
                                Text = "#" + startStr,
                                Color = Color.Gray
                            };
                            list.Add(ylText);
                        }

                        // 注释掉的部分
                        endStr = line.Substring(index2);
                        ylText = new YmlLine()
                        {
                            Text = endStr + "\n",
                            Color = Color.Gray
                        };
                        list.Add(ylText);
                    }
                    else
                    {
                        // 行中无井号
                        startStr = line;

                        index1 = startStr.IndexOf(":");
                        if (index1 > 0)
                        {
                            // key
                            key = startStr.Substring(0, index1);
                            ylText = new YmlLine()
                            {
                                Text = key,
                                Color = Color.OrangeRed
                            };
                            list.Add(ylText);
                            // :
                            ylText = new YmlLine()
                            {
                                Text = mh,
                                Color = Color.Violet
                            };
                            list.Add(ylText);
                            // value
                            value = startStr.Substring(index1 + 1);
                            ylText = new YmlLine()
                            {
                                Text = value + "\n",
                                Color = getTextColor(value)
                            };
                            list.Add(ylText);
                        }
                        else
                        {
                            // 行中无井号,且是不合规的配置值
                            if (string.IsNullOrWhiteSpace(line))
                            {
                                ylText = new YmlLine()
                                {
                                    Text = line + "\n",
                                    Color = Color.OrangeRed
                                };
                            }
                            else
                            {
                                ylText = new YmlLine()
                                {
                                    Text = "#" + line + "\n",
                                    Color = Color.Gray
                                };
                            }                            
                            list.Add(ylText);                            
                        }
                    }
                }
            }
            return list;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public Dictionary<int, List<int>> DistributePoker(out Queue<int> LeftCard, int userCount)
        {
            if (userCount != 3)
            {
                TraceLogEx.Error("201610212210ll  userCount > 6 || userCount < 2   " + userCount);
                LeftCard = null;
                return null;
            }
            Shuffle();
            if (ALLPoker.Count != mNumALLPoker)
            {
                TraceLogEx.Error("20120824154401 ALLPoker!= " + mNumALLPoker);
                LeftCard = null;
                return null;
            }
            Dictionary<int, List<int>> retDic = new Dictionary<int, List<int>>();

            //  1 号的数组 牌
            List<int> firstArr = new List<int>();
            //  2 号的数组 牌                          
            List<int> secondArr = new List<int>();
            //  3 号的数组 牌                          
            List<int> thirdArr = new List<int>();

            for (int i = 0; i < _NumPerUser; i++)
            {
                firstArr.Add(ALLPoker.Dequeue());
                secondArr.Add(ALLPoker.Dequeue());
                thirdArr.Add(ALLPoker.Dequeue());
            }

            retDic.Add(1, firstArr);
            retDic.Add(2, secondArr);
            retDic.Add(3, thirdArr);

            LeftCard = ALLPoker;
            if (ALLPoker.Count != 3)
            {
                TraceLogEx.Error(" 20120824154501ll 给地主抓的牌ALLPoker!= 3. 分牌都分错了");
            }
            return retDic;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetSingleBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _ret = new List<int>();
            if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;

            for (int i = _splitHelper._one.Count - 1; i >= 0; i--)
            {
                if (_splitHelper._one[i] > _lastPoker[0])
                {
                    _ret.Add(_splitHelper._one[i]);
                    break;
                }
            }
            return _ret;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public void SearchStraight()
        {
            if (_shouPai.Count < 5) return;//不足5个牌就不处理的
            List<int> _tempone = new List<int>(_one);
            if (_tempone.Contains((int)LordPokerValueNoColorEnum.p15)) _tempone.Remove((int)LordPokerValueNoColorEnum.p15);    // ,2,小王,大王 不能组成连子
            if (_tempone.Contains((int)LordPokerValueNoColorEnum.jokers16)) _tempone.Remove((int)LordPokerValueNoColorEnum.jokers16);
            if (_tempone.Contains((int)LordPokerValueNoColorEnum.jokersb17)) _tempone.Remove((int)LordPokerValueNoColorEnum.jokersb17);
            if (_tempone.Count < 5) return;//不足5个牌就不处理的
            List<int> _minStraight = new List<int>();
            for (int i = 0; i < _tempone.Count - 1; i++)
            {
                if (_tempone[i] - 1 == _tempone[i + 1])
                {
                    _minStraight.Add(_tempone[i]);
                    if (i + 1 == _tempone.Count - 1) _minStraight.Add(_tempone[i + 1]);//最后一个要加上
                }
                else
                {//可能会出现刚才好5个,而后还有牌,搜索不到
                    _minStraight.Add(_tempone[i]);
                    if (_minStraight.Count >= 5) _straight.Add(_minStraight);
                    _minStraight = new List<int>();
                }
            }
            if (_minStraight.Count >= 5) _straight.Add(_minStraight);//最后一组必须加进去 不然一个长连子没搜索到
        }

19 View Source File : CommandPacket.cs
License : MIT License
Project Creator : 2881099

public CommandPacket InputKey(string key)
        {
            _keyIndexes.Add(_input.Count);
            _input.Add(key);
            return this;
        }

19 View Source File : CommandPacket.cs
License : MIT License
Project Creator : 2881099

public CommandPacket InputKey(string[] keys)
        {
            if (keys == null) return this;
            foreach (var key in keys)
            {
                _keyIndexes.Add(_input.Count);
                _input.Add(key);
            }
            return this;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetThreeBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _ret = new List<int>();
            if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;

            for (int i = _splitHelper._threeList.Count - 1; i >= 0; i--)
            {
                if (_splitHelper._threeList[i] > _lastPoker[0])
                {
                    _ret.Add(_splitHelper._threeList[i]);
                    _ret.Add(_splitHelper._threeList[i]);
                    _ret.Add(_splitHelper._threeList[i]);
                    break;
                }
            }
            return _ret;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public static List<int> SameThreeSort(List<int> PG)
        {
            int _theFourPoker = 0; //如果把4张当三张出并且带4张的另外一张,就需要特殊处理,这里记录出现这种情况的牌的点数. 
            bool FindedThree = false; //已找到三张相同的牌 

            List<int> tempPokerGroup = new List<int>();       //记录三张相同的牌 
            //write by jsw  tempPokerGroup = new tempPokerGroup()
            int count = 0; //记录在连续三张牌前面的翅膀的张数 
            int Four = 0; // 记录是否连续出现三三相同,如果出现这种情况则表明出现把4张牌(炸弹)当中的三张和其他牌配成飞机带翅膀,并且翅膀中有炸弹牌的点数. 
            // 比如有如下牌组: 998887777666 玩家要出的牌实际上应该为 888777666带997,但是经过从大到小的排序后变成了998887777666 一不美观,二不容易比较. 
            for (int i = 2; i < PG.Count; i++) //直接从2开始循环,因为PG[0],PG[1]的引用已经存储在其他变量中,直接比较即可 
            {
                if (PG[i] == PG[i - 2] && PG[i] == PG[i - 1])// 比较PG[i]与PG[i-1],PG[i]与PG[i-2]是否同时相等,如果相等则说明这是三张相同牌 
                {
                    if (Four >= 1) //默认的Four为0,所以第一次运行时这里为false,直接执行else 
                    //一旦连续出现两个三三相等,就会执行这里的if 
                    {
                        _theFourPoker = PG[i]; //当找到四张牌时,记录下4张牌的点数 
                        int _tempchangePoker;
                        for (int k = i; k > 0; k--) //把四张牌中的一张移动到最前面. 
                        {
                            _tempchangePoker = PG[k];
                            PG[k] = PG[k - 1];
                            PG[k - 1] = _tempchangePoker;
                        }
                        count++; //由于此时已经找到三张牌,下面为count赋值的程序不会执行,所以这里要手动+1 
                    }
                    else
                    {
                        Four++; //记录本次循环,因为本次循环找到了三三相等的牌,如果连续两次找到三三相等的牌则说明找到四张牌(炸弹) 
                        tempPokerGroup.Add(PG[i]); //把本次循环的PG[i]记录下来,即记录下三张牌的点数 
                    }
                    FindedThree = true; //标记已找到三张牌 
                }
                else
                {
                    Four = 0; //没有找到时,连续找到三张牌的标志Four归零 
                    if (!FindedThree) //只有没有找到三张牌时才让count增加.如果已经找到三张牌,则不再为count赋值. 
                    {
                        count = i - 1;
                    }
                }
            }
            foreach (int tempPoker in tempPokerGroup) //迭代所有的三张牌点数 
            {
                int _tempchangePoker; //临时交换Poker 
                for (int i = 0; i < PG.Count; i++) //把所有的三张牌往前移动 
                {
                    if (PG[i] == tempPoker) //当PG[i]等于三张牌的点数时 
                    {
                        if (PG[i] == _theFourPoker) //由于上面已经把4张牌中的一张放到的最前面,这张牌也会与tempPoker相匹配所以这里进行处理 
                        // 当第一次遇到四张牌的点数时,把记录四张牌的FourPoker赋值为null,并中断本次循环.由于FourPoker已经为Null,所以下次再次遇到四张牌的点数时会按照正常情况执行. 
                        {
                            _theFourPoker = 0;
                            continue;
                        }
                        _tempchangePoker = PG[i - count];
                        PG[i - count] = PG[i];
                        PG[i] = _tempchangePoker;
                    }
                }
            }
            return PG;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetSameMoreThan3(List<int> paiList)
        {
            Dictionary<int, int> _dicPoker2Count = GetPoker_Count(paiList);
            List<int> _temp = new List<int>();
            foreach (int key in _dicPoker2Count.Keys)
            {
                if (_dicPoker2Count[key] >= 3) _temp.Add(key);
            }
            _temp = OrderPaiLord(_temp);
            if (_temp.Count == 0) TraceLogEx.Error("201701262114 fetal error!");
            return _temp;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetStraightBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _ret = new List<int>();
            if (_lastPoker.Count < 5) return _ret;
            if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
            if (_splitHelper._straight.Count < 0) return _ret;
            foreach (var _onestraight in _splitHelper._straight)
            {
                if (_onestraight.Count < _lastPoker.Count) continue;
                int _tempfirstindex = -1;
                for (int i = 0; i <= _onestraight.Count - _lastPoker.Count; i++) //不安全代码前面必须处理
                {
                    if (_onestraight[i] <= _lastPoker[0]) break;//连子的最大值 都大不过,不找了
                    _tempfirstindex = i;
                }
                if (_tempfirstindex != -1)
                {
                    for (int i = 0; i < _lastPoker.Count; i++)
                    {
                        _ret.Add(_onestraight[_tempfirstindex + i]);
                    }
                }
                if (_ret.Count > 0) break;
            }

            if (_ret.Count == _lastPoker.Count) return _ret;
            return new List<int>();
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

private static List<int> GetLinkerPairBig(List<int> _lastPoker, LordPokerSplitHelper _splitHelper)
        {
            List<int> _ret = new List<int>();
            if (_lastPoker.Count < 6) return _ret;
            if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
            if (_splitHelper._linkerPair.Count < 0) return _ret;
            List<int> _lastLinkPair = new List<int>();//处理成单个,利于比较
            for (int i = 0; i < _lastPoker.Count; i += 2)
            {
                _lastLinkPair.Add(_lastPoker[i]);
            }

            foreach (var _tlinkerpair in _splitHelper._linkerPair)
            {
                if (_tlinkerpair.Count < _lastLinkPair.Count) continue;
                int _tempfirstindex = -1;
                for (int i = 0; i <= _tlinkerpair.Count - _lastLinkPair.Count; i++) //不安全代码前面必须处理
                {
                    if (_tlinkerpair[i] <= _lastLinkPair[0]) break;//连子的最大值 都大不过,不找了
                    _tempfirstindex = i;
                }
                if (_tempfirstindex != -1)
                {
                    for (int i = 0; i < _lastLinkPair.Count; i++)
                    {
                        _ret.Add(_tlinkerpair[_tempfirstindex + i]);
                    }
                }
                if (_ret.Count > 0) break;
            }
            List<int> _retLinkerPair = new List<int>();
            if (_ret.Count == _lastLinkPair.Count)
            {
                _retLinkerPair.AddRange(_ret);
                _retLinkerPair.AddRange(_ret);
            }
            return _retLinkerPair;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public void SearchLinkerPair()
        {
            if (_shouPai.Count < 6) return;//不足6个牌就不处理的
            List<int> _temptwo = new List<int>(_two);
            if (_temptwo.Contains((int)LordPokerValueNoColorEnum.p15)) _temptwo.Remove((int)LordPokerValueNoColorEnum.p15);    // ,2 不能组成连子   
            if (_temptwo.Count < 3) return;//不足6个牌就不处理的

            List<int> _minLinker = new List<int>();
            for (int i = 0; i < _temptwo.Count - 1; i++)
            {
                if (_temptwo[i] - 1 == _temptwo[i + 1])
                {
                    _minLinker.Add(_temptwo[i]);
                    if (i + 1 == _temptwo.Count - 1) _minLinker.Add(_temptwo[i + 1]);//最后一个要加上
                }
                else
                {//可能会出现刚才好3个,而后还有牌,搜索不到
                    _minLinker.Add(_temptwo[i]);
                    if (_minLinker.Count >= 3) _linkerPair.Add(_minLinker);
                    _minLinker = new List<int>();
                }
            }
            if (_minLinker.Count >= 3) _linkerPair.Add(_minLinker);
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public void SearchPlaneWithone()
        {
            if (_shouPai.Count < 4) return;//不足4个牌就不处理的
            if (_three.Count < 2) return;//不足两个三带一
            List<int> _tempthree = new List<int>(_three);
            List<int> _minPlane = new List<int>();
            for (int i = 0; i < _tempthree.Count - 1; i++)
            {
                if (_tempthree[i] - 1 == _tempthree[i + 1])
                {
                    _minPlane.Add(_tempthree[i]);
                    if (i + 1 == _tempthree.Count - 1) _minPlane.Add(_tempthree[i + 1]);//最后一个要加上
                }
                else
                {//可能会出现刚才好2个,而后还有牌,搜索不到
                    _minPlane.Add(_tempthree[i]);
                    if (_minPlane.Count >= 2) _planeWith.Add(_minPlane);
                    _minPlane = new List<int>();
                }
            }
            if (_minPlane.Count >= 2) _planeWith.Add(_minPlane);
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public List<int> GetSingleToFourWith(List<int> planeList)
        {
            List<int> _withtwo = new List<int>();
            if (_single.Count == 0) return _withtwo;
            for (int i = _single.Count - 1; i >= 0; i--)
            {//不能是四带二中的牌  可以带2,带王
                ////if (_single[i] == (int)LordPokerValueNoColorEnum.p15) continue;//2不带用于三带1 只有最后一个手三带一可以用 
                ////if (_single[i] == (int)LordPokerValueNoColorEnum.jokers16 || _single[i] == (int)LordPokerValueNoColorEnum.jokersb17)
                ////{
                ////    continue;//王不带用于三带1 只有最后一个手三带一可以用
                ////}
                bool _issametoPlane = false;
                foreach (int plane in planeList)
                {
                    if (plane == _single[i]) _issametoPlane = true;
                }
                if (_issametoPlane) continue;
                _withtwo.Add(_single[i]);
                if (_withtwo.Count >= 2) break;
            }
            return _withtwo;
        }

19 View Source File : Robot.cs
License : Apache License 2.0
Project Creator : 2881099

public List<int> GetOutsideCard() {
			var allpokers = new List<int>();
			for (int a = 0; a < 54; a++) allpokers.Add(a);

			//除开自己手上的牌
			foreach (var p in this.pokers) allpokers.Remove(p);
			//除开已经打出的牌
			for (var a = 0; a < this.players.Length; a++)
				foreach (var cp in this.players[a].chupai)
					foreach (var p in cp.result.value) allpokers.Remove(p);
			return allpokers;
		}

19 View Source File : Robot.cs
License : Apache License 2.0
Project Creator : 2881099

public void GetPlayerProbableCard() {
			var ret = new Dictionary<int, List<int[]>>();
			var index = this.playerIndex;
			GetPlayerProbableCardPlayerInfo player1 = new GetPlayerProbableCardPlayerInfo { player = this.players[(++index) % 3] };
			GetPlayerProbableCardPlayerInfo player2 = new GetPlayerProbableCardPlayerInfo { player = this.players[(++index) % 3] };
			var cards = this.GetOutsideCard(); //外面所有的牌

			Func<GetPlayerProbableCardPlayerInfo, bool> checkOver = player => {
				if (player.player.pokerLength - player.pokers.Count == 0) {
					
				}
				return false;
			};

			if (this.players[this.playerIndex].role == GamePlayerRole.农民) {
				//判断底牌,确定了的牌
				if (player1.player.role == GamePlayerRole.地主) {
					foreach (var dp in this.dipai) {
						if (cards.Remove(dp)) {
							player1.pokers.Add(dp);
						}
					}
				}
				if (player2.player.role == GamePlayerRole.地主) {
					foreach (var dp in this.dipai) {
						if (cards.Remove(dp)) {
							player2.pokers.Add(dp);
						}
					}
				}
			}

			var dizhu = this.players.Where(a => a.role == GamePlayerRole.地主).First();
			for(var a = 0; a < dizhu.chupai.Count; a++) {

			}

			if (this.players[this.playerIndex].role == GamePlayerRole.地主) {
				//我是地主,我的上家为了顶我出牌套路深,我的下家出牌逻辑较常规,可根据其计算剩余牌型
			}
			if (player1.player.role == GamePlayerRole.地主) {
				//我的下家是地主,地主出牌最没套路,我的上家出牌也没套路
			}
			if (player2.player.role == GamePlayerRole.地主) {
				//我的上家是地主,地主出牌最没牌路,我的下家(也是地主的上家)出牌会顶地主套路深

			}
		}

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private int GetLvSelectedIndex()
        {
            int index = -1;
            lvSelecteds.Clear();
            try
            {
                if (lvServers.SelectedIndices.Count <= 0)
                {
                    UI.Show(UIRes.I18N("PleaseSelectServer"));
                    return index;
                }

                index = lvServers.SelectedIndices[0];
                foreach (int i in lvServers.SelectedIndices)
                {
                    lvSelecteds.Add(i);
                }
                return index;
            }
            catch
            {
                return index;
            }
        }

19 View Source File : RoutingRuleSettingForm.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private int GetLvSelectedIndex()
        {
            int index = -1;
            lvSelecteds.Clear();
            try
            {
                if (lvRoutings.SelectedIndices.Count <= 0)
                {
                    UI.Show(UIRes.I18N("PleaseSelectRules"));
                    return index;
                }

                index = lvRoutings.SelectedIndices[0];
                foreach (int i in lvRoutings.SelectedIndices)
                {
                    lvSelecteds.Add(i);
                }
                return index;
            }
            catch
            {
                return index;
            }
        }

19 View Source File : CapsuleHand.cs
License : MIT License
Project Creator : 39M

private Mesh generateCylinderMesh(float length) {
      Mesh mesh = new Mesh();
      mesh.name = "GeneratedCylinder";
      mesh.hideFlags = HideFlags.DontSave;

      List<Vector3> verts = new List<Vector3>();
      List<Color> colors = new List<Color>();
      List<int> tris = new List<int>();

      Vector3 p0 = Vector3.zero;
      Vector3 p1 = Vector3.forward * length;
      for (int i = 0; i < _cylinderResolution; i++) {
        float angle = (Mathf.PI * 2.0f * i) / _cylinderResolution;
        float dx = CYLINDER_RADIUS * Mathf.Cos(angle);
        float dy = CYLINDER_RADIUS * Mathf.Sin(angle);

        Vector3 spoke = new Vector3(dx, dy, 0);

        verts.Add((p0 + spoke) * transform.lossyScale.x);
        verts.Add((p1 + spoke) * transform.lossyScale.x);

        colors.Add(Color.white);
        colors.Add(Color.white);

        int triStart = verts.Count;
        int triCap = _cylinderResolution * 2;

        tris.Add((triStart + 0) % triCap);
        tris.Add((triStart + 2) % triCap);
        tris.Add((triStart + 1) % triCap);

        tris.Add((triStart + 2) % triCap);
        tris.Add((triStart + 3) % triCap);
        tris.Add((triStart + 1) % triCap);
      }

      mesh.SetVertices(verts);
      mesh.SetIndices(tris.ToArray(), MeshTopology.Triangles, 0);
      mesh.RecalculateBounds();
      mesh.RecalculateNormals();
      ;
      mesh.UploadMeshData(true);

      return mesh;
    }

19 View Source File : RuntimeGizmoManager.cs
License : MIT License
Project Creator : 39M

private void generateMeshes() {
      _cubeMesh = new Mesh();
      _cubeMesh.name = "RuntimeGizmoCube";
      _cubeMesh.hideFlags = HideFlags.HideAndDontSave;

      List<Vector3> verts = new List<Vector3>();
      List<int> indexes = new List<int>();

      Vector3[] faces = new Vector3[] { Vector3.forward, Vector3.right, Vector3.up };
      for (int i = 0; i < 3; i++) {
        addQuad(verts, indexes, faces[(i + 0) % 3], -faces[(i + 1) % 3], faces[(i + 2) % 3]);
        addQuad(verts, indexes, -faces[(i + 0) % 3], faces[(i + 1) % 3], faces[(i + 2) % 3]);
      }

      _cubeMesh.SetVertices(verts);
      _cubeMesh.SetIndices(indexes.ToArray(), MeshTopology.Quads, 0);
      _cubeMesh.RecalculateNormals();
      _cubeMesh.RecalculateBounds();
      _cubeMesh.UploadMeshData(true);

      _wireCubeMesh = new Mesh();
      _wireCubeMesh.name = "RuntimeWireCubeMesh";
      _wireCubeMesh.hideFlags = HideFlags.HideAndDontSave;

      verts.Clear();
      indexes.Clear();

      for (int dx = 1; dx >= -1; dx -= 2) {
        for (int dy = 1; dy >= -1; dy -= 2) {
          for (int dz = 1; dz >= -1; dz -= 2) {
            verts.Add(0.5f * new Vector3(dx, dy, dz));
          }
        }
      }

      addCorner(indexes, 0, 1, 2, 4);
      addCorner(indexes, 3, 1, 2, 7);
      addCorner(indexes, 5, 1, 4, 7);
      addCorner(indexes, 6, 2, 4, 7);

      _wireCubeMesh.SetVertices(verts);
      _wireCubeMesh.SetIndices(indexes.ToArray(), MeshTopology.Lines, 0);
      _wireCubeMesh.RecalculateBounds();
      _wireCubeMesh.UploadMeshData(true);

      _wireSphereMesh = new Mesh();
      _wireSphereMesh.name = "RuntimeWireSphereMesh";
      _wireSphereMesh.hideFlags = HideFlags.HideAndDontSave;

      verts.Clear();
      indexes.Clear();

      int totalVerts = CIRCLE_RESOLUTION * 3;
      for (int i = 0; i < CIRCLE_RESOLUTION; i++) {
        float angle = Mathf.PI * 2 * i / CIRCLE_RESOLUTION;
        float dx = 0.5f * Mathf.Cos(angle);
        float dy = 0.5f * Mathf.Sin(angle);

        for (int j = 0; j < 3; j++) {
          indexes.Add((i * 3 + j + 0) % totalVerts);
          indexes.Add((i * 3 + j + 3) % totalVerts);
        }

        verts.Add(new Vector3(dx, dy, 0));
        verts.Add(new Vector3(0, dx, dy));
        verts.Add(new Vector3(dx, 0, dy));
      }

      _wireSphereMesh.SetVertices(verts);
      _wireSphereMesh.SetIndices(indexes.ToArray(), MeshTopology.Lines, 0);
      _wireSphereMesh.RecalculateBounds();
      _wireSphereMesh.UploadMeshData(true);
    }

19 View Source File : RuntimeGizmoManager.cs
License : MIT License
Project Creator : 39M

private void addQuad(List<Vector3> verts, List<int> indexes, Vector3 normal, Vector3 axis1, Vector3 axis2) {
      indexes.Add(verts.Count + 0);
      indexes.Add(verts.Count + 1);
      indexes.Add(verts.Count + 2);
      indexes.Add(verts.Count + 3);

      verts.Add(0.5f * (normal + axis1 + axis2));
      verts.Add(0.5f * (normal + axis1 - axis2));
      verts.Add(0.5f * (normal - axis1 - axis2));
      verts.Add(0.5f * (normal - axis1 + axis2));
    }

19 View Source File : RuntimeGizmoManager.cs
License : MIT License
Project Creator : 39M

private void addCorner(List<int> indexes, int a, int b, int c, int d) {
      indexes.Add(a); indexes.Add(b);
      indexes.Add(a); indexes.Add(c);
      indexes.Add(a); indexes.Add(d);
    }

19 View Source File : PlyHandler.cs
License : MIT License
Project Creator : 3DBear

private static List<int> GetTriangles(byte[] bytes, PlyHeader header)
        {
            var toSkip = header.VertexCount * GetByteCountPerVertex(header);
            var triangles = new List<int>();
            int facesRead = 0;
            int bytesRead = 0;
            int bytesPerTriangleIndex = 4;
            while (facesRead < header.FaceCount)
            {
                var faceIndex = toSkip + bytesRead;
                var indexCount = bytes[faceIndex];
                if (indexCount == 3)
                {
                    for (int i = 0; i < indexCount; i++)
                    {
                        triangles.Add(System.BitConverter.ToInt32(bytes.SubArray(faceIndex + 1 + i * bytesPerTriangleIndex, bytesPerTriangleIndex), 0));
                    }
                    bytesRead += 1 + indexCount * bytesPerTriangleIndex;
                }
                else if (indexCount == 4)
                {
                    var tmp = new List<int>();
                    for (int i = 0; i < indexCount; i++)
                    {
                        tmp.Add(System.BitConverter.ToInt32(bytes.SubArray(faceIndex + 1 + i * bytesPerTriangleIndex, bytesPerTriangleIndex), 0));
                    }
                    triangles.AddRange(QuadToTriangles(tmp));
                    bytesRead += 1 + indexCount * bytesPerTriangleIndex;
                }
                else
                {
                    Debug.LogWarning("Warning: Found a face with more than 4 vertices, skipping...");
                }

                facesRead++;
            }
            return triangles;
        }

19 View Source File : CutMesh.cs
License : GNU Affero General Public License v3.0
Project Creator : 3drepo

private Mesh GetMesh(RepoForUnity.MeshLocation[] meshLocations)
    {
        List<Vector3> vertices = new List<Vector3>();
        List<Vector3> normal = new List<Vector3>();
        List<int> triangles = new List<int>();

        foreach (var entry in meshLocations)
        {
            var go = GameObject.Find(entry.superMeshID);
            var meshFilter = go.GetComponent<MeshFilter>();
            var superMesh = meshFilter.mesh;
            Dictionary<int, int> vIndexChange = new Dictionary<int, int>();
            for (int i = 0; i < superMesh.uv2.Length; ++i)
            {
                if (superMesh.uv2[i].y == entry.index)
                {
                    vIndexChange[i] = vertices.Count;
                    vertices.Add(superMesh.vertices[i]);
                    normal.Add(superMesh.normals[i]);
                }
            }

            for (int i = 0; i < superMesh.triangles.Length; ++i)
            {
                var index = superMesh.triangles[i];
                if (vIndexChange.ContainsKey(index))
                {
                    triangles.Add(vIndexChange[index]);
                }
            }
        }

        var mesh = new Mesh();
        mesh.vertices = vertices.ToArray();
        mesh.normals = normal.ToArray();
        mesh.triangles = triangles.ToArray();
        return mesh;
    }

19 View Source File : TipsManager.cs
License : MIT License
Project Creator : 404Lcc

public void ClearAllTipss()
        {
            List<int> idList = new List<int>();
            foreach (object item in tipss.Keys)
            {
                idList.Add((int)item);
            }
            foreach (int item in idList)
            {
                Tips tips = GetTips(item);
                if (tips == null) return;
                tipsPool.Enqueue(tips);
                tipss.Remove(item);
            }
        }

19 View Source File : TipsWindowManager.cs
License : MIT License
Project Creator : 404Lcc

public void ClearAllTipsWindows()
        {
            List<int> idList = new List<int>();
            foreach (object item in tipsWindows.Keys)
            {
                idList.Add((int)item);
            }
            foreach (int item in idList)
            {
                TipsWindow tipsWindow = GetTipsWindow(item);
                if (tipsWindow == null) return;
                tipsWindowPool.Enqueue(tipsWindow);
                tipsWindows.Remove(item);
            }
        }

19 View Source File : FuzzerShouldBeDocumented.cs
License : Apache License 2.0
Project Creator : 42skillz

[Test]
        public void Simplest_usage_with_numbers()
        {
            // Instantiates the Fuzzer
            var fuzzer = new Fuzzer();

            var results = new List<int>();
            for (var i = 0; i < 50; i++)
            {
                var integer = fuzzer.GeneratePositiveInteger(maxValue: 3);
                results.Add(integer);
            }

            var findGreaterNumberThanMaxValue = results.Any(x => x > 3);
            var findAtLeastOneNumberWithTheMaxValue = results.Any(x => x == 3);

            Check.That(findGreaterNumberThanMaxValue).IsFalse();
            Check.That(findAtLeastOneNumberWithTheMaxValue).IsTrue();
        }

19 View Source File : FuzzerWithItsOwnDeterministicCapabilitiesShould.cs
License : Apache License 2.0
Project Creator : 42skillz

[Test]
        public void Be_Deterministic_when_specifying_an_existing_seed()
        {
            var seed = 1226354269;
            var fuzzer = new Fuzzer(seed);

            var fuzzedIntegers = new List<int>();
            for (var i = 0; i < 10; i++)
            {
                var positiveInteger = fuzzer.GeneratePositiveInteger();
                fuzzedIntegers.Add(positiveInteger);
            }

            //Check.That(fuzzedDecimal).IsEqualTo(720612366.000000740230018m);
            Check.That(fuzzedIntegers).ContainsExactly(33828652, 221134346, 1868176041, 1437724735, 1202622988, 974525956, 1605572379, 1127364048, 1453698000, 141079432);
        }

19 View Source File : NumberFuzzerShould.cs
License : Apache License 2.0
Project Creator : 42skillz

[TestCase(500)]
        public void GeneratePositiveInteger_with_an_inclusive_upper_bound(int attempts)
        {
            var fuzzer = new Fuzzer();

            var maxValue = 3;

            var generatedPositiveNumbers = new List<int>();
            for (var i = 0; i < attempts; i++)
            {
                generatedPositiveNumbers.Add(fuzzer.GeneratePositiveInteger(maxValue));
            }

            Check.That(generatedPositiveNumbers.Any(n => n == 3)).IsTrue();
            Check.That(generatedPositiveNumbers.Any(n => n > 3)).IsFalse();
        }

19 View Source File : NumberFuzzerShould.cs
License : Apache License 2.0
Project Creator : 42skillz

[TestCase(500)]
        public void GenerateIntegers_with_an_inclusive_upper_bound(int attempts)
        {
            var fuzzer = new Fuzzer();

            var maxValue = 3;

            var generatedPositiveNumbers = new List<int>();
            for (var i = 0; i < attempts; i++)
            {
                generatedPositiveNumbers.Add(fuzzer.GenerateInteger(-2, maxValue));
            }

            Check.That(generatedPositiveNumbers.Any(n => n == 3)).IsTrue();
            Check.That(generatedPositiveNumbers.Any(n => n > 3)).IsFalse();
        }

19 View Source File : Util.cs
License : MIT License
Project Creator : 499116344

public static string GET_GTK(string skey)
        {
            var arg = "tencentQQVIP123443safde&!%^%1282";
            var list = new List<int>();
            var num = 5381;
            list.Add(172192);
            var i = 0;
            for (var length = skey.Length; i < length; i++)
            {
                int num2 = Encoding.UTF8.GetBytes(skey)[i];
                list.Add((num << 5) + num2);
                num = num2;
            }

            var stringBuilder = new StringBuilder();
            for (i = 0; i < list.Count; i++)
            {
                stringBuilder.Append(list[i].ToString());
            }

            return QQTea.Md5(stringBuilder + arg);
        }

19 View Source File : RoomAppService.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826

public async Task<ResultDto> Update(int id, RoomInput item)
        {
            var result = new ResultDto { Message = "" };
            try
            {
                var room = await _roomDomainService.Get(id);
                if (room == null)
                {
                    result.Message = $"房间 {id} 不存在!";
                    return result;
                }


                var content = room.ComparisonTo(item);
                int west = room.West;
                int east = room.East;
                int south = room.South;
                int north = room.North;

                _mapper.Map(item, room);

                List<int> changedIds = new List<int>();
                changedIds.Add(room.Id);

                //已修改
                if (west != room.West)
                {
                    //原来已设置
                    if (west > 0)
                    {
                        var oldRoomWest = await _roomDomainService.Get(west);
                        if (oldRoomWest != null)
                        {
                            oldRoomWest.East = 0;
                            oldRoomWest.EastName = "";
                            changedIds.Add(oldRoomWest.Id);
                        }
                    }
                }

                //已设置
                if (room.West > 0 && room.West != room.Id)
                {
                    var roomWest = await _roomDomainService.Get(room.West);
                    if (roomWest != null && roomWest.MapId == room.MapId)
                    {
                        roomWest.East = room.Id;
                        roomWest.EastName = room.Name;
                        room.WestName = roomWest.Name;
                        changedIds.Add(roomWest.Id);
                    }
                    else
                    {
                        room.West = 0;
                        room.WestName = "";
                    }
                }
                else
                {
                    room.West = 0;
                    room.WestName = "";
                }


                if (east != room.East)
                {
                    if (east > 0)
                    {
                        var oldRoomEast = await _roomDomainService.Get(east);
                        if (oldRoomEast != null)
                        {
                            oldRoomEast.West = 0;
                            oldRoomEast.WestName = "";
                            changedIds.Add(oldRoomEast.Id);
                        }
                    }
                }

                if (room.East > 0 && room.East != room.Id)
                {
                    var roomEast = await _roomDomainService.Get(room.East);
                    if (roomEast != null && roomEast.MapId == room.MapId)
                    {
                        roomEast.West = room.Id;
                        roomEast.WestName = room.Name;
                        room.EastName = roomEast.Name;
                        changedIds.Add(roomEast.Id);
                    }
                    else
                    {
                        room.East = 0;
                        room.EastName = "";
                    }
                }
                else
                {
                    room.East = 0;
                    room.EastName = "";
                }


                if (south != room.South)
                {
                    if (south > 0)
                    {
                        var oldRoomSouth = await _roomDomainService.Get(south);
                        if (oldRoomSouth != null)
                        {
                            oldRoomSouth.North = 0;
                            oldRoomSouth.NorthName = "";
                            changedIds.Add(oldRoomSouth.Id);
                        }
                    }
                }

                if (room.South > 0 && room.South != room.Id)
                {
                    var roomSouth = await _roomDomainService.Get(room.South);
                    if (roomSouth != null && roomSouth.MapId == room.MapId)
                    {
                        roomSouth.North = room.Id;
                        roomSouth.NorthName = room.Name;
                        room.SouthName = roomSouth.Name;
                        changedIds.Add(roomSouth.Id);
                    }
                    else
                    {
                        room.South = 0;
                        room.SouthName = "";
                    }
                }
                else
                {
                    room.South = 0;
                    room.SouthName = "";
                }



                if (north != room.North)
                {
                    if (north > 0)
                    {
                        var oldRoomNorth = await _roomDomainService.Get(north);
                        if (oldRoomNorth != null)
                        {
                            oldRoomNorth.South = 0;
                            oldRoomNorth.SouthName = "";
                            changedIds.Add(oldRoomNorth.Id);
                        }
                    }
                }

                if (room.North > 0 && room.North != room.Id)
                {
                    var roomNorth = await _roomDomainService.Get(room.North);
                    if (roomNorth != null && roomNorth.MapId == room.MapId)
                    {
                        roomNorth.South = room.Id;
                        roomNorth.SouthName = room.Name;
                        room.NorthName = roomNorth.Name;
                        changedIds.Add(roomNorth.Id);
                    }
                    else
                    {
                        room.North = 0;
                        room.NorthName = "";
                    }
                }
                else
                {
                    room.North = 0;
                    room.NorthName = "";
                }

                await _operatorLogDomainService.AddSuccess(new OperatorLogEnreplacedy
                {
                    Type = OperatorLogType.修改房间,
                    Content = $"Id = {id},Data = {content}"
                });

                await Commit();

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                await _operatorLogDomainService.AddError(new OperatorLogEnreplacedy
                {
                    Type = OperatorLogType.修改房间,
                    Content = $"Data={JsonConvert.SerializeObject(item)},ErrorMessage={result.Message}"
                });
                await Commit();
            }
            return result;
        }

19 View Source File : CloudBoxCrop.cs
License : GNU Lesser General Public License v3.0
Project Creator : 9and3

public PointCloud CropBox(PointCloud cloud, List<Brep> boxes, bool inverse = false, bool parallel = false) {


            bool[] flags = new bool[cloud.Count];

            foreach (var brep in boxes) {


                brep.Surfaces[0].TryGetPlane(out Plane plane);
                Box box = new Box(plane, brep);

                Transform xform = Transform.PlaneToPlane(box.Plane, Plane.WorldXY);
                Transform xformI = Transform.PlaneToPlane(Plane.WorldXY, box.Plane);

                PointCloud cloudCopy = new PointCloud(cloud);

                Box b = new Box(box.Plane, new Point3d[] { box.PointAt(0, 0, 0), box.PointAt(1, 1, 1) });
             
                cloudCopy.Transform(xform);
                b.Transform(xform);
                Point3d Min = b.PointAt(0, 0, 0);
                Point3d Max = b.PointAt(1, 1, 1);
                //Rhino.RhinoDoc.ActiveDoc.Objects.AddBox(b);

                System.Threading.Tasks.Parallel.For(0, cloudCopy.Count, i => {

                    if (flags[i]) return;
                    var p = cloudCopy[i].Location;
                    bool flag = (Min.X < p.X) && (Max.X > p.X) && (Min.Y < p.Y) && (Max.Y > p.Y) &&  (Min.Z < p.Z) && (Max.Z > p.Z);
                    if (flag) flags[i] = true;

                });
            }



            int count = 0;
            List<int> idList = new List<int>();
            for (int i = 0; i < cloud.Count; i++) {
                bool f = inverse ? !flags[i] : flags[i];
                if (f) {
                    idList.Add(i);
                    count++;
                }
            }

            int[] idArray = idList.ToArray();
            Point3d[] points = new Point3d[count];
            Vector3d[] normals = new Vector3d[count];
            Color[] colors = new Color[count];

            System.Threading.Tasks.Parallel.For(0, idArray.Length, i => {


                int id = idArray[i];
                var p = cloud[(int)id];
                points[i] = p.Location;
                normals[i] = p.Normal;
                colors[i] = p.Color;

            });

            PointCloud croppedCloud = new PointCloud();
            croppedCloud.AddRange(points, normals, colors);



           
            //for (int i = 0; i < cloud.Count; i++) {
            //    bool f = inverse ? !flags[i] : flags[i];
            //    if (f) {
            //        if (cloud.ContainsNormals) {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Normal, cloud[i].Color);
            //        } else {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Color);
            //        }
            //    }
            //}
            return croppedCloud;

        }

19 View Source File : CloudSection.cs
License : GNU Lesser General Public License v3.0
Project Creator : 9and3

public PointCloud SectionCloud(PointCloud cloud, List<Plane> planes,  double tol = 0.001, bool project = false) {

            bool[] flags = new bool[cloud.Count];
            int[] cID = new int[cloud.Count];

          

            int count = 1;
            foreach (Plane plane in planes) {

                   double[] eq = plane.GetPlaneEquation();
                   double denom = 1 / Math.Sqrt(eq[0] * eq[0] + eq[1] * eq[1] + eq[2] * eq[2]);


                System.Threading.Tasks.Parallel.For(0, cloud.Count, i => {
                    // for (int i = 0; i < cloud_.Count; i++) {

                    if (flags[i]) return;

                    if (Math.Abs(FastPlaneToPt(denom, eq[0], eq[1], eq[2], eq[3], cloud[i].Location)) <= tol) {
                        flags[i] = true;
                        cID[i] = count;
                    }


                });

                count++;
            }

            int cc = 0;
            List<int> idList = new List<int>();
            for (int i = 0; i < cloud.Count; i++) {
                //bool f = inverse ? !flags[i] : flags[i];
                if (flags[i]) {
                    idList.Add(i);
                    cc++;
                }
            }

            int[] idArray = idList.ToArray();
            Point3d[] points = new Point3d[cc];
            Vector3d[] normals = new Vector3d[cc];
            Color[] colors = new Color[cc];

            System.Threading.Tasks.Parallel.For(0, idArray.Length, i => {


                int id = idArray[i];
                var p = cloud[(int)id];
                points[i] = p.Location;
                normals[i] = p.Normal;
                colors[i] = p.Color;

            });

            PointCloud croppedCloud = new PointCloud();
            croppedCloud.AddRange(points, normals, colors);

            //PointCloud croppedCloud = new PointCloud();
            //for (int i = 0; i < cloud.Count; i++) {
            //    //bool f = inverse ? !flags[i] : flags[i];
            //    bool f =  flags[i];
            //    if (f) {
            //        if (cloud.ContainsNormals) {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Normal, cloud[i].Color);
            //        } else {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Color);
            //        }
            //    }
            //}


            if (project) {
               // if (planes.Count == 1) {
                    croppedCloud.Transform(Rhino.Geometry.Transform.PlanarProjection(planes[0]));
                //} else {

                //    for (int i = 0; i < cloud.Count; i++) {

                //    }
                }
                return croppedCloud;

            }

See More Examples