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


C# ArrayList.Remove方法代码示例

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


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

示例1: playWithArrayList

        static void playWithArrayList()
        {
            ArrayList lst = new ArrayList() {1,2,3};
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            int a = 0;
            lst.Add(a = 15);
            lst.Add(null);
            lst.Add(new Car("diesel", 150, 200));
            lst.Add(10.25f);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            lst.Insert(2, "insert");
            lst.Add(15);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            lst.RemoveAt(1);
            lst.Add(a);
            lst.Remove(a);
            lst.Remove(15);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            Console.WriteLine(lst.IndexOf(15));

            foreach (Object obj in lst)
                Console.WriteLine(obj);
        }
开发者ID:NivekAlunya,项目名称:csharp,代码行数:27,代码来源:Program.cs

示例2: initTubesArrayList

 void initTubesArrayList()
 {
     tubes = new ArrayList ();
     //Tube array
     foreach (Transform tbAr in transform) {
         //actual tube
         foreach (Transform tb in tbAr) {
             tubes.Add(tb.gameObject);
         }
         tubes.Remove(tbAr.gameObject);
     }
     tubes.Remove(this.gameObject);
     Debug.Log ("tube count: " + tubes.Count);
 }
开发者ID:BenVanCitters,项目名称:SummitMapping,代码行数:14,代码来源:MicTubes.cs

示例3: RemoveChildrenFrom

 public void RemoveChildrenFrom(ArrayList behs)
 {
     foreach(FishBehaviour child in children) {
        child.RemoveChildrenFrom(behs);
        behs.Remove(child);
        }
 }
开发者ID:IlyaBokovenko,项目名称:spear-fishing,代码行数:7,代码来源:FishBehaviour.cs

示例4: calculateCheckpoints

    public void calculateCheckpoints()
    {
        LevelPropertiesScript properties = LevelPropertiesScript.sharedInstance();
        this.checkpoints = new ArrayList(properties.powerups.Count);

        ArrayList placesToGo = new ArrayList(properties.powerups.Count);
        foreach (GameObject powerup in properties.powerups)
        {
            placesToGo.Add(powerup.transform.position);
        }

        Vector3 nextPos = (Vector3)placesToGo[0];
        this.checkpoints.Add(nextPos);
        placesToGo.RemoveAt(0);
        while (placesToGo.Count > 0)
        {
            float minDistance = float.MaxValue;
            Vector3 closestPosition = nextPos;
            foreach (Vector3 position in placesToGo)
            {
                float dist = Vector3.SqrMagnitude(position - nextPos);
                if (dist < minDistance)
                {
                    closestPosition = position;
                    minDistance = dist;
                }
            }

            nextPos = closestPosition;
            this.checkpoints.Add(closestPosition);
            placesToGo.Remove(closestPosition);
        }
    }
开发者ID:ricardperez,项目名称:Momino,代码行数:33,代码来源:ShortestPathScript.cs

示例5: setTeam

    public Team team; // which team are you on

    #endregion Fields

    #region Methods

    void setTeam( Team newTeam)
    {
        team = newTeam;

        enemyTeams = new ArrayList () { Team.Left, Team.Right, Team.Boss };
        enemyTeams.Remove (newTeam);	//fuck
    }
开发者ID:gelum,项目名称:TBA,代码行数:13,代码来源:Character.cs

示例6: Shuffle

 public void Shuffle()
 {
     ArrayList unshuffledCards = new ArrayList(cards);
     ArrayList shuffledCards = new ArrayList();
     while (unshuffledCards.Count > 0){
         Card card = (Card)unshuffledCards[(int)UnityEngine.Random.Range(0, unshuffledCards.Count)];
         unshuffledCards.Remove(card);
         shuffledCards.Add(card);
     }
     cards = shuffledCards;
 }
开发者ID:kiichi7,项目名称:Lies_and_Seductions,代码行数:11,代码来源:Deck.cs

示例7: Update

    void Update()
    {
        timeSinceLastLaunch += Time.deltaTime;

                if (waitedInitialDelay) {

                        if (!instantiatedLaunchers) {
                                instantiatedLaunchers = true;
                                Instantiate (launchersPrefab, Vector3.zero, Quaternion.identity);
                        }

                        ArrayList launchers = new ArrayList (GameObject.FindGameObjectsWithTag ("Launcher"));

                        if (launchers.Count == 0) {
                                ++level;
                                staggered = level % 2 == 0;
                                bulletVelocityRange += bulletVelocityRangeStep;
                                //			textScript.allowTextToDisappear = true;
                                //			textScript.DisplayText ("Welcome to Level: " + (level - 1));

                                timeSinceLastLaunch = 0.0f;
                                waitedInitialDelay = false;
                                instantiatedLaunchers = false;
                        } else {
                                int numToLaunch = Mathf.Min (level, launchers.Count);

                                if (timeSinceLastLaunch > timeBetweenLaunches || (staggered && timeSinceLastLaunch > timeBetweenLaunches / (float)numToLaunch)) {
                                        timeSinceLastLaunch = 0.0f;

                                        for (int i = 0; i < (staggered ? 1 : numToLaunch); ++i) {
                                                if (launchers.Count == 0)
                                                        return;
                                                int launcherIndex = Random.Range (0, launchers.Count);
                                                BulletLauncherBehavior launchScript = ((GameObject)launchers [launcherIndex]).GetComponent<BulletLauncherBehavior> ();
                                                float randBulletVelocity = Random.Range (bulletVelocity - bulletVelocityRange, bulletVelocity + bulletVelocityRange);
                                                if (!launchScript.destroyed)
                                                        launchScript.LaunchBullet (randBulletVelocity, bulletLifetime);
                                                else
                                                        --i;
                                                launchers.Remove (launcherIndex);
                                        }
                                }
                        }
                } else {
                        if (timeSinceLastLaunch > initialDelayTime) {
                                timeSinceLastLaunch = 0.0f;
                                waitedInitialDelay = true;
                        }
                }
    }
开发者ID:jacobhanshaw,项目名称:DodgeFight,代码行数:50,代码来源:CoreLogic.cs

示例8: skillActivate

    void skillActivate()
    {
        ArrayList gos;

        gos = GameObject.FindGameObjectWithTag("TheVoid").GetComponent<VoidAI>().GetVoidTiles();
        //gos = GameObject.FindGameObjectsWithTag("VoidTile");
        Vector3 playerPos = Player.transform.position;
        range = playerLvl;

        tempGos=(ArrayList)gos.Clone();

        foreach (GameObject go in gos) {

                if (go.transform.position.x <= playerPos.x + range &&
                    go.transform.position.x >= playerPos.x - range ||
                    go.transform.position.x == playerPos.x)
                {
                    if(go.transform.position.y <= playerPos.y + range &&
                       go.transform.position.y >= playerPos.y - range ||
                       go.transform.position.y == playerPos.y)
                    {
                        tempGos.Remove(go);
                        Destroy(go);
                        xp++;

                        //createXp(go.transform.position.x,go.transform.position.y,go.transform.position.z + 5.0f);
                        clonexpUp = Instantiate(xpUpPrefab, new Vector3(go.transform.position.x,go.transform.position.y,go.transform.position.z + 5),Quaternion.identity) as Transform;
                        clonexpUp.transform.Rotate(new Vector3(0,1,0),180);
                        clonexpUp.transform.localScale = new Vector3(0.2f,0.2f,0.0f);
                        //textIn3D = new On3dText(go.transform.position.x,go.transform.position.y,go.transform.position.z + 5.0f);

                    }
                }
        }

        gos.Clear();

        foreach (GameObject tmp in tempGos)
        {
            gos.Add (tmp);
        }
    }
开发者ID:GL666,项目名称:GameJamInfinity,代码行数:42,代码来源:PlayerSkill.cs

示例9: Start

    // Use this for initialization
    void Start()
    {
        //creates an array of an undetermined size and type
        ArrayList aList = new ArrayList();

        //create an array of all objects in the scene
        Object[] AllObjects = GameObject.FindObjectsOfType(typeof(Object)) as Object[];

        //iterate through all objects
        foreach (Object o in AllObjects)
        {
            if (o.GetType() == typeof(GameObject))
            {
                aList.Add(o);
            }
        }

        if (aList.Contains(SpecificObject))
        {
            Debug.Log(aList.IndexOf(SpecificObject));
        }

        if (aList.Contains(gameObject))
        {
            aList.Remove(gameObject);
        }

        //initialize the AllGameObjects array
        AllGameObjects = new GameObject[aList.Count];

        //copy the list to the array
        DistanceComparer dc = new DistanceComparer();
        dc.Target = gameObject;
        aList.Sort(dc);

        aList.CopyTo(AllGameObjects);
        ArrayList sorted = new ArrayList();
        sorted.AddRange(messyInts);
        sorted.Sort();
        sorted.Reverse();
        sorted.CopyTo(messyInts);
    }
开发者ID:kurtzhang,项目名称:UnityProjects,代码行数:43,代码来源:ArrayLists.cs

示例10: getNeighbors

    public static ArrayList getNeighbors(int [,,] mapData, IntVector3 point)
    {
        //print ("getNeighbors: i: " + i + " j: " + j + " k: " + k);
        ArrayList neighbors = new ArrayList ();

        neighbors.Add (new IntVector3 (point.x- 1, point.y,  point.z));
        neighbors.Add (new IntVector3 (point.x+ 1, point.y,  point.z));
        neighbors.Add (new IntVector3 (point.x, point.y - 1,  point.z));
        neighbors.Add (new IntVector3 (point.x, point.y + 1,  point.z));
        neighbors.Add (new IntVector3 (point.x, point.y,  point.z - 1));
        neighbors.Add (new IntVector3 (point.x, point.y,  point.z + 1));

        for (int index=0; index<neighbors.Count; index++) {
            IntVector3 neighborPoint = (IntVector3)neighbors [index];
            if (! isVoxelOccupied (mapData, neighborPoint)) {
                neighbors.Remove (neighborPoint);
                index--;
            }
        }

        return neighbors;
    }
开发者ID:Zulban,项目名称:viroid,代码行数:22,代码来源:MDView.cs

示例11: Update

    public void Update()
    {
        if (!Pause.IsPaused()){

            ArrayList copyList = new ArrayList(dialogueControllers);
            foreach (GenericDialogueController dialogueController in copyList){
                //Debug.Log("GenericDialogueAgent.Update: iterating");
                bool finished = dialogueController.UpdateGenericDialogueController();
                if (finished){
                    //Debug.Log("--- removing dialogue controller");
                    dialogueControllers.Remove(dialogueController);
                }

            }

            if (GameTime.GetRealTimeSecondsPassed() > nextRoundTimeInSeconds){
                GameObject[] genericNPCs = CharacterManager.GetGenericNPCs();
                ArrayList potentialSpeakers = new ArrayList();
                foreach (GameObject genericNPC in genericNPCs){
                    ActionRunner routineCreator = (ActionRunner)genericNPC.GetComponent("ActionRunner");
                    if (routineCreator.CanStartDialogue(false)){
                        potentialSpeakers.Add(genericNPC);
                    }
                }
                if (potentialSpeakers.Count >= NUMBER_OF_SPEAKERS){
                    GameObject[] speakers = new GameObject[NUMBER_OF_SPEAKERS];
                    for (int i = 0; i < NUMBER_OF_SPEAKERS; i++){
                        GameObject speaker = (GameObject)potentialSpeakers[Random.Range(0, potentialSpeakers.Count)];
                        speakers[i] = speaker;
                        potentialSpeakers.Remove(speaker);
                    }
                    dialogueControllers.Add(new GenericDialogueController(speakers));
                    nextRoundTimeInSeconds += Random.Range(0.0f, MAX_CYCLE_LENGTH_IN_SECONDS);
                }
            }

        }
    }
开发者ID:kiichi7,项目名称:Lies_and_Seductions,代码行数:38,代码来源:GenericDialogueAgent.cs

示例12: GetHiddenValues

 /// <summary>
 /// Returns array list from hidden field.
 /// </summary>
 /// <param name="field">Hidden field with values separated with |</param>
 private static ArrayList GetHiddenValues(HiddenField field)
 {
     string hiddenValue = field.Value.Trim('|');
     ArrayList list = new ArrayList();
     string[] values = hiddenValue.Split('|');
     foreach (string value in values)
     {
         if (!list.Contains(value))
         {
             list.Add(value);
         }
     }
     list.Remove("");
     return list;
 }
开发者ID:KuduApps,项目名称:Kentico,代码行数:19,代码来源:UniGrid.ascx.cs

示例13: shoot

    /// <summary>
    /// 射击
    /// </summary>
    public void shoot()
    {
        //print("2");
        if(!shootBool)
        {
            return ;
        }
        RaycastHit[] hits;
        Vector3 vc3=vReticle;
        vc3.x +=rectWidth / 2;
        //print(vc3.y);
        vc3.y =Screen.height-rectHeight/2-vc3.y;
        vc3.z = 0;
        ray = camera.ScreenPointToRay(vc3);

           // mainCamera.transform.position = ray.origin;

        hits = Physics.RaycastAll(ray.origin, transform.forward, 100.0F);
        print(ray.origin);

        ArrayList lifeLists = new ArrayList();
        if (hits.Length > 0)
        {
            print(hits.Length);
            for (int i = 0; i <= (hits.Length - 1); i++)
            {
                Transform hit = hits[i].transform;
                do
                {
                    Life lifeTemp = hit.gameObject.GetComponent<Life>();
                    if (lifeTemp)
                    {
                            foreach (Life lList in lifeLists)
                            {
                                if (lList == lifeTemp)
                                {
                                    lifeLists.Remove(lList);
                                }
                            }
                        lifeLists.Add(lifeTemp);
                        lifeTemp = null;
                    }
                    hit = hit.parent;
                }
                while (hit);
            }
        }
        foreach (Life lList in lifeLists)
        {
            lList.injure(sniperObject.GetComponent<SniperEntrance>().getSniperData().damage);
        }

        shootBool=false;
        shootTime.enabled=true;
    }
开发者ID:Seraphli,项目名称:TheInsectersWar,代码行数:58,代码来源:SniperMode.cs

示例14: FloodFillAll

	public void FloodFillAll () {
		
		area = 0;
		int areaTimeStamp = Mathf.RoundToInt (Random.Range (0,10000));
		int searched = 0;
		ArrayList open = new ArrayList ();
		Node current = null;
		ArrayList areaColorsArr = new ArrayList ();
		areaColorsArr.Add (new Color (Random.value,Random.value,Random.value));
		
		int totalWalkableNodeAmount = 0;//The amount of nodes which are walkable
		
		for (int y=0;y<grids.Length;y++) {//Height
			Grid grid = grids[y];
			for (int z=0;z<grid.depth;z++) {//Depth
				for (int x=0;x<grid.width;x++) {//Depth
					Node node = GetNode (x,y,z);
					if (node.walkable) {
						totalWalkableNodeAmount++;
					}
				}
			}
		}
			
		while (searched < totalWalkableNodeAmount) {
			area++;
			
			areaColorsArr.Add (area <= presetAreaColors.Length ? presetAreaColors[area-1] : new Color (Random.value,Random.value,Random.value));
			if (area > 400) {
				Debug.Log ("Preventing possible Infinity Loop (Searched " + searched+" nodes in the flood fill pass)");
				break;
			}
			for (int y=0;y<grids.Length;y++) {//Height
				Grid grid = grids[y];
				for (int z=0;z<grid.depth;z++) {//Depth
					for (int x=0;x<grid.width;x++) {//Depth
						Node node = GetNode (x,y,z);
						if (node.walkable && node.areaTimeStamp != areaTimeStamp && node.enabledConnections.Length>0) {
							node.areaTimeStamp = areaTimeStamp;
							//searched++;
							open.Add (node);
							z = grid.depth;
							x = grid.width;
							y = grids.Length;
						}
					}
				}
			}
			
			if (open.Count==0) {
				searched=totalWalkableNodeAmount;
				area--;
				break;
			}
			
			while (open.Count > 0) {
				searched++;
				
				
				if (searched > totalWalkableNodeAmount) {
					Debug.LogError ("Infinity Loop, can't flood fill more than the total node amount (System Failure)");
					break;
				}
				current = open[0] as Node;
				current.area = area;
				current.areaTimeStamp = areaTimeStamp;
				open.Remove (current);
				
				for (int i=0;i<current.enabledConnections.Length;i++) {
					if (current.enabledConnections[i].endNode.areaTimeStamp != areaTimeStamp) {
						current.enabledConnections[i].endNode.areaTimeStamp = areaTimeStamp;
						open.Add (current.enabledConnections[i].endNode);
						
					}
				}
			}
			open.Clear ();
		}
		
		areaColors = areaColorsArr.ToArray (typeof(Color)) as Color[];
		
		Debug.Log ("Grid contains "+(area)+" Area(s)");
	}
开发者ID:hyper-active,项目名称:virtual-reality,代码行数:83,代码来源:AstarPath.cs

示例15: checkPath

    public TDPath checkPath(TDMap map, TDTile start, int maxStamina)
    {
        TDTile selected = new TDTile();
        TDTile finalSelected = new TDTile();
        TDTile pathRun = new TDTile();
        ArrayList finalPath = new ArrayList();
        ArrayList unvisited = new ArrayList();
        for (int i = start.position - maxStamina - maxStamina * map.getWidth(); i < start.position + maxStamina + maxStamina * map.getWidth(); i++)
        {
            if (i > 0 && i < map.getWidth() * map.getHeight())
            {
                map.getTile(i).distance = 20000;
                map.getTile(i).previousTile = null;
                unvisited.Add(map.getTile(i));
            }
            Debug.Log("On position " + i);
            if (i % map.getWidth() == start.x + maxStamina)
            {

                i += map.getWidth() - maxStamina * 2 - 1;
                Debug.Log("Switched Rows " + i);

            }
        }
        map.getTile(start.position).distance = 0;
        int looped = 0;
        int finalDistance = -1;
        while (unvisited.Count > 0 && !selected.equals(map.getTile((int)currentTileCoord.x, (int)currentTileCoord.z)) && selected.distance < maxStamina)
        {
            looped++;
            selected.distance = 200000;
            for (int i = 0; i < unvisited.Count; i++)
            {
                TDTile comparing = (TDTile)unvisited[i];
                if (comparing.distance < selected.distance)
                {

                    selected = comparing;
                    if (selected.equals(map.getTile((int)currentTileCoord.x, (int)currentTileCoord.z)))
                    {
                        if (selected.distance > maxStamina)
                        {
                            return null;
                        }
                        finalDistance = selected.distance;
                        finalSelected = selected;
                        pathRun = finalSelected;
                        while (pathRun.previousTile != null)
                        {
                            finalPath.Add(pathRun);
                            pathRun = pathRun.previousTile;
                        }

                        return new TDPath(finalPath, finalDistance);
                    }
                    Debug.Log(" Selected: " + selected + " " + selected.distance + "looped: " + looped);
                }
                unvisited.Remove(selected);
                for (int j = 0; j < selected.findNeighbors().Length; j++)
                {
                    TDTile neighbor = map.getTile(selected.findNeighbors()[j]);
                    if (neighbor != null)
                    {
                        if (unvisited.Contains(neighbor))
                        {
                            int alternate = selected.distance + 1;
                            if (alternate < neighbor.distance)
                            {
                                neighbor.distance = alternate;
                                neighbor.previousTile = selected;
                            }

                        }
                    }
                }
            }
        }
        return null;
    }
开发者ID:Laser11,项目名称:Pacifica_s_Landing,代码行数:79,代码来源:TDSelector.cs


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