本文整理汇总了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);
}
示例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);
}
示例3: RemoveChildrenFrom
public void RemoveChildrenFrom(ArrayList behs)
{
foreach(FishBehaviour child in children) {
child.RemoveChildrenFrom(behs);
behs.Remove(child);
}
}
示例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);
}
}
示例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
}
示例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;
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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)");
}
示例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;
}