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


C# List.AddUnique方法代码示例

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


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

示例1: ToUnique

        public static List<Diagnostic> ToUnique(this List<Diagnostic> source) {
            var diagnostics = new List<Diagnostic>();

            foreach (var diagnostic in source) {
                diagnostics.AddUnique(diagnostic);
            }

            return diagnostics;
        }
开发者ID:IInspectable,项目名称:Nav.Language.Extensions,代码行数:9,代码来源:DiagnosticExtensions.cs

示例2: GenerateTableForRoots

 public void GenerateTableForRoots(string[] rootNames)
 {
     List<Project> projs = new List<Project>();
     foreach (string rootName in rootNames)
     {
         Project proj = SolutionParser.ProjTable[rootName];
         foreach (Project depProj in proj.ProjectTree)
         {
             projs.AddUnique(depProj);
         }
     }
     GenerateTableForProjects(projs.ToArray());
 }
开发者ID:tort32,项目名称:DepAnalyzer,代码行数:13,代码来源:ProjectsDepMatrix.cs

示例3: MostrarListExtension

        private static void MostrarListExtension()
        {
            var nomes = new List<String> { "ADÃO", "EVA", "CAIM", "ABEL" };

            nomes.AddUnique("ADÃO");
            nomes.AddUnique("COBRA");

            nomes.Add("ADÃO");

            foreach (var nome in nomes) { Console.WriteLine(nome); }

            Console.WriteLine();

            Console.WriteLine(nomes.Count("ADÃO"));

            Console.WriteLine(new String('-', 80));

            var numeros = new List<int> { 1, 2, 3, 4, 5, 6, 7 };

            numeros.AddUnique(5);

            foreach (var numero in numeros) { Console.WriteLine(numero); }
        }
开发者ID:50minutos,项目名称:MOC-10265,代码行数:23,代码来源:Program.cs

示例4: Collide

    public void Collide(List<GameObject> collisions, int offsetX = 0, int offsetY = 0, int mask = Physics2D.DefaultRaycastLayers, string objectTag = null, List<IntegerCollider> potentialCollisions = null)
    {
        if (potentialCollisions == null)
            potentialCollisions = this.GetPotentialCollisions(0, 0, offsetX, offsetY, mask);

        if (potentialCollisions.Count == 0 || (potentialCollisions.Count == 1 && potentialCollisions[0] == this))
            return;
        
        foreach (IntegerCollider collider in potentialCollisions)
        {
            if (collider != this && (objectTag == null || collider.tag == objectTag))
            {
                if (this.Overlaps(collider, offsetX, offsetY))
                    collisions.AddUnique(collider.gameObject);
            }
        }
    }
开发者ID:DrSkipper,项目名称:Watchlist,代码行数:17,代码来源:IntegerCollider.cs

示例5: enableShielding

        void enableShielding()
        {
            // print("enableShielding()");
            disableShielding();

            var attached=getFairingParams();
            if (!sideFairing) return;

            // get all parts in range
            var parts=new List<Part>();
            var colliders=Physics.OverlapSphere(part.transform.TransformPoint(lookupCenter), lookupRad, 1);
            for (int i=colliders.Length-1; i>=0; --i)
            {
              var p=colliders[i].gameObject.GetComponentUpwards<Part>();
              if (p!=null) parts.AddUnique(p);
            }
            // print("got "+parts.Count+" nearby parts");

            // filter parts
            float sizeSqr=lookupRad*lookupRad*4;
            float boundCylRadSq=boundCylRad*boundCylRad;

            bool isInline = (sideFairing.inlineHeight>0);
            bool topClosed=false;

            Matrix4x4 w2l=Matrix4x4.identity, w2lb=Matrix4x4.identity;
            Bounds topBounds=default(Bounds);

            if (isInline)
            {
              w2l=part.transform.worldToLocalMatrix;
              w2lb=w2l;
              for (int i=0; i<3; ++i)
            for (int j=0; j<3; ++j)
              w2lb[i, j]=Mathf.Abs(w2lb[i, j]);

              topBounds=new Bounds(new Vector3(0, boundCylY1, 0), Vector3.one*(sideFairing.topRad*2));
            }

            for (int pi=0; pi<parts.Count; ++pi)
            {
              var pt=parts[pi];

              // check special cases
              if (pt==part) { shieldedParts.Add(pt); continue; }

              bool isSide=false;
              for (int i=0; i<attached.Length; ++i) if (attached[i].attachedPart==pt) { isSide=true; break; }
              if (isSide) continue;

              // print("checking part "+pt.partName+" "+pt.partInfo.title);

              // check if the top is closed in the inline case
              var bounds=pt.GetRendererBounds();
              var box=PartGeometryUtil.MergeBounds(bounds, pt.partTransform);

              if (isInline && !topClosed && pt.vessel==vessel)
              {
            var wb=box; wb.Expand(sideFairing.sideThickness*4);
            var b=new Bounds(w2l.MultiplyPoint3x4(wb.center), w2lb.MultiplyVector(wb.size));
            if (b.Contains(topBounds.min) && b.Contains(topBounds.max)) topClosed=true;
              }

              // check if too big to fit
              // if (box.size.sqrMagnitude>sizeSqr) continue;

              // check if the centroid is within fairing bounds
              var c=part.transform.InverseTransformPoint(PartGeometryUtil.FindBoundsCentroid(bounds, null));

              float y=c.y;
              if (y<boundCylY0 || y>boundCylY1) continue;

              float xsq=new Vector2(c.x, c.z).sqrMagnitude;
              if (xsq>boundCylRadSq) continue;

              // accurate centroid check
              float x=Mathf.Sqrt(xsq);
              bool inside=false;

              for (int i=1; i<shape.Length; ++i)
              {
            var p0=shape[i-1];
            var p1=shape[i];
            if (p0.y>p1.y) { var p=p0; p0=p1; p1=p; }

            if (y<p0.y || y>p1.y) continue;

            float dy=p1.y-p0.y, r;
            if (dy<=1e-6f) r=(p0.x+p1.x)*0.5f;
            else r=(p1.x-p0.x)*(y-p0.y)/dy+p0.x;

            if (x>r) continue;

            inside=true;
            break;
              }

              if (!inside) continue;

              shieldedParts.Add(pt);
//.........这里部分代码省略.........
开发者ID:ItMustBeACamel,项目名称:ProceduralFairings,代码行数:101,代码来源:FairingShielding.cs

示例6: Resolve

        public override bool Resolve(List targetList, string name, EntityType flags)
        {
            // Try to resolve name as a generic parameter
            if (NameResolutionService.IsFlagSet(flags, EntityType.Type))
            {
                foreach (GenericParameterDeclaration gpd in Method.GenericParameters)
                {
                    if (gpd.Name == name)
                    {
                        targetList.AddUnique(gpd.Entity);
                        return true;
                    }
                }
            }

            return base.Resolve(targetList, name, flags);
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:17,代码来源:InternalGenericMethod.cs

示例7: Telekinesis


//.........这里部分代码省略.........
                                         t2.Toggle(null);
                                     }
                                     B.Add("The " + feature_name + " flies into " + tilename + ". ",t2);
                                     t2.Toggle(null);
                                     Screen.WriteMapChar(current_row,current_col,mem[current_row,current_col]);
                                 }
                                 else{
                                     B.Add("The " + feature_name + " flies into " + t2.TheName(true) + ". ",t2);
                                     if(impact_damage_dice > 0){
                                         t2.Bump(M.tile[current_row,current_col].DirectionOf(t2));
                                     }
                                     Screen.WriteMapChar(current_row,current_col,mem[current_row,current_col]);
                                 }
                                 knockback_strength = 0;
                                 break;
                             }
                             else{
                                 if(t2.actor() != null){
                                     B.Add("The " + feature_name + " flies into " + t2.actor().TheName(true) + ". ",t2);
                                     if(t2.actor().type != ActorType.SPORE_POD && !t2.actor().HasAttr(AttrType.SELF_TK_NO_DAMAGE)){
                                         t2.actor().TakeDamage(DamageType.NORMAL,DamageClass.PHYSICAL,R.Roll(impact_damage_dice,6),user,"colliding with a " + feature_name);
                                     }
                                     knockback_strength = 0;
                                     Screen.WriteMapChar(t2.row,t2.col,vis);
                                     Screen.WriteMapChar(current_row,current_col,mem[current_row,current_col]);
                                     current_row = t2.row;
                                     current_col = t2.col;
                                     break;
                                 }
                                 else{
                                     if(t2.Is(FeatureType.WEB)){ //unless perhaps grenades should get stuck and explode in the web?
                                         t2.RemoveFeature(FeatureType.WEB);
                                     }
                                     Screen.WriteMapChar(t2.row,t2.col,vis);
                                     Screen.WriteMapChar(current_row,current_col,mem[current_row,current_col]);
                                     current_row = t2.row;
                                     current_col = t2.col;
                                     Game.GLUpdate();
                                     Thread.Sleep(20);
                                 }
                             }
                             //M.Draw();
                             knockback_strength--;
                         }
                         Tile current = M.tile[current_row,current_col];
                         if(grenade){
                             B.Add("The grenade explodes! ",current);
                             current.ApplyExplosion(1,user,"an exploding grenade");
                         }
                         if(barrel){
                             B.Add("The barrel smashes! ",current);
                             List<Tile> cone = current.TilesWithinDistance(1).Where(x=>x.passable);
                             List<Tile> added = new List<Tile>();
                             foreach(Tile t3 in cone){
                                 foreach(int dir in U.FourDirections){
                                     if(R.CoinFlip() && t3.TileInDirection(dir).passable){
                                         added.AddUnique(t3.TileInDirection(dir));
                                     }
                                 }
                             }
                             cone.AddRange(added);
                             foreach(Tile t3 in cone){
                                 t3.AddFeature(FeatureType.OIL);
                                 if(t3.actor() != null && !t3.actor().HasAttr(AttrType.OIL_COVERED,AttrType.SLIMED)){
                                     if(t3.actor().IsBurning()){
                                         t3.actor().ApplyBurning();
                                     }
                                     else{
                                         t3.actor().attrs[AttrType.OIL_COVERED] = 1;
                                         B.Add(t3.actor().YouAre() + " covered in oil. ",t3.actor());
                                         if(t3.actor() == player){
                                             Help.TutorialTip(TutorialTopic.Oiled);
                                         }
                                     }
                                 }
                             }
                             if(flaming_barrel){
                                 current.ApplyEffect(DamageType.FIRE);
                             }
                         }
                         if(torch){
                             current.AddFeature(FeatureType.FIRE);
                         }
                         user.attrs[AttrType.SELF_TK_NO_DAMAGE] = 0;
                     }
                     else{
                         if(wand){
                             return true;
                         }
                         return false;
                     }
                 }
             }
         }
     }
     else{
         return false;
     }
     return true;
 }
开发者ID:ptrefall,项目名称:ForaysIntoNorrendrin,代码行数:101,代码来源:Effect.cs

示例8: ResolveMember

        protected bool ResolveMember(List targetList, string name, EntityType flags)
        {
            bool found = false;

            // Try to resolve name as a member
            foreach (IEntity entity in GetMembers())
            {
                if (entity.Name == name && NameResolutionService.IsFlagSet(flags, entity.EntityType))
                {
                    targetList.AddUnique(entity);
                    found = true;
                }
            }

            return found;
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:16,代码来源:AbstractInternalType.cs

示例9: GetSetMethods

 IEntity[] GetSetMethods(IEntity[] entities)
 {
     List setMethods = new List();
     for (int i=0; i<entities.Length; ++i)
     {
         IProperty property = entities[i] as IProperty;
         if (null != property)
         {
             IMethod setter = property.GetSetMethod();
             if (null != setter)
             {
                 setMethods.AddUnique(setter);
             }
         }
     }
     return ToEntityArray(setMethods);
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:17,代码来源:ProcessMethodBodies.cs

示例10: Resolve

        public virtual bool Resolve(List targetList, string name, EntityType flags)
        {
            bool found = false;
            foreach (IEntity member in GetMembers())
            {
                if (!NameResolutionService.IsFlagSet(flags, member.EntityType)) continue;

                if (member.Name == name)
                {
                    targetList.AddUnique(member);
                    found = true;
                }
            }

            if (IsInterface)
            {
                if (_typeSystemServices.ObjectType.Resolve(targetList, name, flags))
                {
                    found = true;
                }

                foreach (IType baseInterface in GetInterfaces())
                {
                    found |= baseInterface.Resolve(targetList, name, flags);
                }
            }
            else
            {
                if (!found || TypeSystemServices.ContainsMethodsOnly(targetList))
                {
                    IType baseType = BaseType;
                    if (null != baseType)
                    {
                        found |= baseType.Resolve(targetList, name, flags);
                    }
                }
            }
            return found;
        }
开发者ID:boo,项目名称:boo-lang,代码行数:39,代码来源:ExternalType.cs

示例11: GetModTypes

 public static void GetModTypes()
 {
     _ModTypes = new List<Type>();
     List<Assembly> asms = new List<Assembly>();
     asms.AddRange(AssemblyLoader.loadedAssemblies.Select(la => la.assembly));
     asms.AddUnique(typeof(PQSMod_VertexSimplexHeightAbsolute).Assembly);
     asms.AddUnique(typeof(PQSLandControl).Assembly);
     foreach (Type t in asms.SelectMany(a => a.GetTypes()))
     {
         _ModTypes.Add(t);
     }
 }
开发者ID:FrancoisHarvey,项目名称:Kopernicus,代码行数:12,代码来源:Injector.cs

示例12: TriggerTrap


//.........这里部分代码省略.........
             List<Tile> new_area = AddGaseousFeature(FeatureType.POISON_GAS,num);
             if(new_area.Count > 0){
                 B.Add("Poisonous gas fills the area! ",this);
                 Event.RemoveGas(new_area,300,FeatureType.POISON_GAS,18);
             }
         }
         Toggle(actor());
         break;
     }
     case TileType.SCALDING_OIL_TRAP:
     {
         if(actor_here){
             B.Add("Scalding oil pours over " + actor().TheName(true) + "! ",this);
             if(actor().TakeDamage(DamageType.FIRE,DamageClass.PHYSICAL,R.Roll(3,6),null,"a scalding oil trap")){
                 if(!actor().HasAttr(AttrType.BURNING,AttrType.SLIMED) && !IsBurning()){
                     actor().attrs[AttrType.OIL_COVERED] = 1;
                     B.Add(actor().YouAre() + " covered in oil. ",actor());
                     if(actor() == player){
                         Help.TutorialTip(TutorialTopic.Oiled);
                     }
                 }
             }
         }
         else{
             B.Add("Scalding oil pours over the floor. ",this);
         }
         List<Tile> covered_in_oil = new List<Tile>{this};
         List<Tile> added = new List<Tile>();
         for(int i=0;i<2;++i){
             foreach(Tile t in covered_in_oil){
                 foreach(int dir in U.FourDirections){
                     Tile neighbor = t.TileInDirection(dir);
                     if(neighbor.DistanceFrom(this) == 1 && R.OneIn(3) && neighbor.passable && !covered_in_oil.Contains(neighbor)){
                         added.AddUnique(neighbor);
                     }
                 }
             }
             covered_in_oil.AddRange(added);
         }
         foreach(Tile t in covered_in_oil){
             t.AddFeature(FeatureType.OIL);
         }
         Toggle(actor());
         break;
     }
     case TileType.FLING_TRAP:
     {
         List<int> valid_dirs = new List<int>();
         foreach(int d in U.EightDirections){
             bool good = true;
             Tile current = this;
             for(int i=0;i<2;++i){
                 current = current.TileInDirection(d);
                 if(current == null || (!current.passable && !current.Is(TileType.BARREL,TileType.CRACKED_WALL,TileType.DOOR_C,TileType.HIDDEN_DOOR,TileType.POISON_BULB,TileType.STANDING_TORCH))){
                     good = false; //try to pick directions that are either open, or that have interesting things to be knocked into
                     break;
                 }
             }
             if(good){
                 valid_dirs.Add(d);
             }
         }
         Toggle(actor());
         int dir = -1;
         if(valid_dirs.Count > 0){
             dir = valid_dirs.Random();
开发者ID:ptrefall,项目名称:ForaysIntoNorrendrin,代码行数:67,代码来源:Tile.cs

示例13: moveX

    // Returns actual amount applied to movement
    private float moveX(float dx, List<GameObject> collisions, List<GameObject> horizontalCollisions, List<IntegerCollider> potentialCollisions)
    {
        _positionModifier.x += dx;
        int unitMove = Mathf.RoundToInt(_positionModifier.x);

        if (unitMove != 0)
        {
            int moves = 0;
            int unitDir = Math.Sign(unitMove);
            _positionModifier.x -= unitMove;

            while (unitMove != 0)
            {
                int oldCount = horizontalCollisions.Count;
                this.integerCollider.Collide(horizontalCollisions, unitDir, 0, this.CollisionMask, null, potentialCollisions);

                if (horizontalCollisions.Count > oldCount)
                {
                    for (int i = oldCount; i < horizontalCollisions.Count; ++i)
                    {
                        collisions.AddUnique(horizontalCollisions[i]);

                        if (((1 << horizontalCollisions[i].layer) & this.HaltMovementMask) != 0)
                        {
                            _positionModifier.x = 0.0f;
                            _haltX = true;
                            return moves;
                        }
                    }
                }

                this.transform.position += new Vector3(unitDir, 0, 0);
                unitMove -= unitDir;
                ++moves;
            }
        }

        return dx;
    }
开发者ID:DrSkipper,项目名称:ScrapyardComrades,代码行数:40,代码来源:Actor2D.cs

示例14: moveY

    private float moveY(float dy, List<GameObject> collisions, List<GameObject> verticalCollisions, List<IntegerCollider> potentialCollisions)
    {
        _positionModifier.y += dy;
        int unitMove = Mathf.RoundToInt(_positionModifier.y);

        if (unitMove != 0)
        {
            int moves = 0;
            int unitDir = Math.Sign(unitMove);
            _positionModifier.y -= unitMove;

            while (unitMove != 0)
            {
                int oldCount = verticalCollisions.Count;
                this.integerCollider.Collide(verticalCollisions, 0, unitDir, this.CollisionMask, null, potentialCollisions);

                if (verticalCollisions.Count > oldCount)
                {
                    for (int i = oldCount; i < verticalCollisions.Count; ++i)
                    {
                        collisions.AddUnique(verticalCollisions[i]);

                        if (((1 << verticalCollisions[i].layer) & this.HaltMovementMask) != 0)
                        {
                            _positionModifier.y = 0.0f;
                            _haltY = true;
                            return moves;
                        }
                    }
                }

                this.transform.position += new Vector3(0, unitDir, 0);
                unitMove -= unitDir;
                ++moves;
            }
        }

        return dy;
    }
开发者ID:DrSkipper,项目名称:ScrapyardComrades,代码行数:39,代码来源:Actor2D.cs

示例15: IsLegal


//.........这里部分代码省略.........
         if(AllowAllCornerConnections){
             if(!map[rotated[2]].IsWall() && !map[rotated[3]].IsWall()){
                 return false;
             }
             if(!map[rotated[6]].IsWall() && !map[rotated[5]].IsWall()){
                 return false;
             }
             if(!map[rotated[4]].IsWall()){ //if the corner isn't a wall...
                 if(!map[rotated[3]].IsWall() && !map[rotated[5]].IsWall()){
                     return false;
                 }
                 if(map[rotated[3]].IsWall() && map[rotated[5]].IsWall()){ //...reject it if there's not exactly 1 adjacent corridor
                     return false;
                 }
             }
         }
         else{
             foreach(int dir in new int[]{3,4,5}){
                 if(!map[rotated[dir]].IsWall()){
                     return false;
                 }
             }
         }
         break;
     }
     case CellType.RoomInteriorCorner:
     {
         List<int> wall_dirs = new List<int>();
         List<int> edge_dirs = new List<int>();
         foreach(int dir in DiagonalDirections){
             pos neighbor = p.PosInDir(dir);
             if(BoundsCheck(neighbor) && map[neighbor].IsWall()){
                 wall_dirs.Add(dir);
                 edge_dirs.AddUnique(dir.RotateDir(true));
                 edge_dirs.AddUnique(dir.RotateDir(false));
             }
         }
         if(wall_dirs.Count == 0){
             return false; //no room found, error
         }
         foreach(int dir in EightDirections){
             if(wall_dirs.Contains(dir)){
                 if(!map[p.PosInDir(dir)].IsWall()){
                     return false;
                 }
             }
             else{
                 if(edge_dirs.Contains(dir)){
                     if(!map[p.PosInDir(dir)].IsRoomEdgeType()){
                         return false;
                     }
                 }
                 else{
                     if(!map[p.PosInDir(dir)].IsRoomType()){
                         return false;
                     }
                 }
             }
         }
         break;
     }
     case CellType.CorridorHorizontal:
         foreach(int dir in new int[]{2,8}){
             pos next = p;
             for(int i=1;i<=MinimumSpaceBetweenCorridors;++i){
                 next = next.PosInDir(dir);
开发者ID:ptrefall,项目名称:ForaysIntoNorrendrin,代码行数:67,代码来源:Schism.cs


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