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


C# ArrayList.Contains方法代码示例

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


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

示例1: addIntoListBySingleComplexCandy

    //高级单个糖果的爆炸逻辑
    void addIntoListBySingleComplexCandy(GameObject target,ArrayList _arr,ArrayList _arr2)
    {
        if (target && _arr != null) {
            Candy candy = target.GetComponent<Candy>();
            int type1 = candy.type;
            int count = type1/100;
            int dir = (type1 - count*100)/10;
            //单4
            if(count == 4)
            {
                if(dir == 1)
                {
                    //横
                    for(int j = 0 ; j < mapLine ; j++)
                    {
                        GameObject t = getCandyAt(candy.row,j);
                        if(t && !_arr.Contains(t) && !_arr2.Contains(t))
                        {
                            _arr.Add(t);
                            _arr2.Add(t);
                        }
                    }
                }else
                {
                    //列
                    for(int i = 0 ; i < mapRow ; i++)
                    {
                        GameObject t = getCandyAt(i,candy.line);
                        if(t && !_arr.Contains(t) && !_arr2.Contains(t))
                        {
                            _arr.Add(t);
                            _arr2.Add(t);
                        }
                    }
                }
            }
            //单5 t
            if(count == 5)
            {

                for(int i = candy.row - 1 ;i <= candy.row + 1; i++)
                {
                    for(int j = candy.line - 1; j <= candy.line + 1 ;j++)
                    {
                        GameObject t = getCandyAt(i,j);
                        if(t && !_arr.Contains(t) && !_arr2.Contains(t))
                        {
                            _arr.Add(t);
                            _arr2.Add(t);
                        }
                    }
                }
            }
        }
    }
开发者ID:yizhengtutu,项目名称:unityCandy,代码行数:56,代码来源:MapControl.cs

示例2: SpawnLayer

    void SpawnLayer(int layer, ArrayList spots, bool destroyLastLayer)
    {
        if (destroyLastLayer) {
            foreach(Object o in lastLayer) {
                Destroy(o);
            }
        }
        else {
            lastLayer.Clear();
        }

        int counter = 0;

        int i, j;

        // Top left -> top right
        j = layer;
        for (i = -layer; i < layer; i++) {
            counter++;
            if (spots.Contains(counter)) {
                lastLayer.Add(Instantiate (Atom, transform.position + new Vector3(i, j, 1), transform.rotation));
            }
        }
        // Top right -> bottom right
        i = layer;
        for (j = layer; j > -layer; j--) {
            counter++;
            if (spots.Contains(counter)) {
                lastLayer.Add(Instantiate (Atom, transform.position + new Vector3(i, j, 1), transform.rotation));
            }
        }
        // bottom right -> bottom left
        j = -layer;
        for (i = layer; i > -layer; i--) {
            counter++;
            if (spots.Contains(counter)) {
                lastLayer.Add(Instantiate (Atom, transform.position + new Vector3(i, j, 1), transform.rotation));
            }
        }
        // bottom left -> top right
        i = -layer;
        for (j = -layer; j < layer; j++) {
            counter++;
            if (spots.Contains(counter)) {
                lastLayer.Add(Instantiate (Atom, transform.position + new Vector3(i, j, 1), transform.rotation));
            }
        }
    }
开发者ID:GlobalGameJam2014OrlandoDwnTwn,项目名称:GGJ2014,代码行数:48,代码来源:SpecialGrow.cs

示例3: bttnChangePlayerProfile_Click

    protected void bttnChangePlayerProfile_Click(object sender, EventArgs e)
    {
        ISession session = (ISession)Context.Items[Constant.NHibernateSessionSign];
        this.Hero.Biography = this.txtPersonalText.Text;

        ArrayList lstExtension = new ArrayList();
        lstExtension.Add(".jpg");
        lstExtension.Add(".gif");
        lstExtension.Add(".png");
        lstExtension.Add(".jpeg");

        if (this.fileAvatar.HasFile)
        {
            string filename = fileAvatar.FileName;
            if (!lstExtension.Contains(Path.GetExtension(filename).ToLower()))
                this.lblAvatarError.Text = "Sai định dạng file ảnh";
            else
            {
                if (!Functions.UploadImage(fileAvatar.FileContent, Server.MapPath("~/data/images/heroes/") + this.Hero.ID.ToString() + ".jpg"))
                    this.lblAvatarError.Text = "Có lỗi khi upload ảnh. Vui lòng thử lại sau vài phút";
                else
                {
                    this.Hero.Avatar = true;
                    this.aDeleteAvatar.Visible = true;
                }
            }
        }

        session.Update(this.Hero);
    }
开发者ID:DF-thangld,项目名称:web_game,代码行数:30,代码来源:HeroDetails.ascx.cs

示例4: OnTriggerEnter2D

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag ("Paddle")) {
            GameObject[] bricks = BrickController.GetBricks ();
            ArrayList hitBricks = new ArrayList ();

            if (bricks.Length <= destroyBlockCount) {
                //Just break all the bricks if we only have as many bricks left as we should hit
                hitBricks.AddRange (bricks);
            } else {
                //Select some random bricks.
                for (int i = 0; i < destroyBlockCount; i++) {
                    while (hitBricks.Count < i + 1) {
                        int index = Random.Range (0, bricks.Length - 1);
                        GameObject b = bricks [index];
                        if (!hitBricks.Contains (b)) {
                            hitBricks.Add (b);
                        }
                    }
                }
            }

            //Destroy some Bricks!
            foreach (GameObject b in hitBricks) {
                BrickController.HitBrick (b);
            }
            //Remove the carrot
            Destroy (this.gameObject);
        }
    }
开发者ID:jd4rider,项目名称:bunnybreakout,代码行数:30,代码来源:CatchCarrot.cs

示例5: DetectOtherObjects

    //we are only testing in one direction at a time
    public static bool DetectOtherObjects(float[] dir, Transform startingFrom)
    {
        float[] localDir = new float[2] { dir[0], dir[1] }; //since we are passing by reference we need to make our own local
        localDir[0] *= 0.9f; //scale the distance
        localDir[1] *= 0.9f;
        RaycastHit2D[] hits = Physics2D.LinecastAll(new Vector2(startingFrom.position.x + localDir[0], startingFrom.position.y + localDir[1]),
                                     new Vector2(startingFrom.position.x + (localDir[0] * 1.1f), startingFrom.position.y + (localDir[1] * 1.1f)));

        //Debug.DrawLine(new Vector3(startingFrom.position.x + localDir[0], startingFrom.position.y + localDir[1]),
        //               new Vector3(startingFrom.position.x + (localDir[0] * 1.1f), startingFrom.position.y + (localDir[1] * 1.1f)), Color.blue, 30.0f, false);

        //blacklist pseudo-children, and other placement pieces
        ArrayList blackList = new ArrayList();
        for (int j = 0; j < hits.Length; j++)
        {
            if (hits[j].collider.GetComponent<PlacementBottom>() != null &&
                hits[j].collider.GetComponent<PlacementBottom>().pseudoParent == startingFrom)
            {
                blackList.Add(j);
            }
        }

        for (int j = 0; j < hits.Length; j++)
        {
            if (blackList.Contains(j)) continue; //skip pseudo-children and placement pieces

            //okay, we found one, don't place here!
            return true;
        }

        return false;
    }
开发者ID:Harmonickey,项目名称:AlexCSPortfolio,代码行数:33,代码来源:BuildingManager.cs

示例6: CalculatePoints

    void CalculatePoints(bool isPhoto)
    {
        ArrayList targetHits = new ArrayList ();
        foreach (RaycastHit hit in eyes.hits)
        {
            if (hit.transform && hit.transform.tag == "Girl" && !targetHits.Contains(hit.transform.gameObject.GetHashCode()))
            {
                targetAcquire = true;
                targetHits.Add(hit.transform.gameObject.GetHashCode());
                int points = (int)(Mathf.Min(10, 20 * Mathf.Max(0f, 1 - hit.distance/eyes.fovMaxDistance)));
                if(isPhoto)
                {
                    points *= 100;
                }

                GameState gs = GameManager.getInstance().getGameState();

                if(gs == GameState.Stealth)
                    points *=2;
                else if(gs == GameState.Detected)
                    points /=2;

                GameManager.getInstance().updatePoints(points);
            }
        }
    }
开发者ID:MaDumont,项目名称:LesVoyeurs,代码行数:26,代码来源:VoyeurScript.cs

示例7: findDetachedVoxels

    public static ArrayList findDetachedVoxels(int [,,] mapData, int stopCode, IntVector3 point)
    {
        /*
        where i,j,k is a recently destroyed block, returns a list of IntVector3s of all blocks that should
        be detached, as well as the size of the blob that would contain them.
        */
        ArrayList detachedVoxels = new ArrayList ();

        allVisitedVoxels = new ArrayList ();
        ArrayList seeds = MDView.getNeighbors (mapData, point);

        for (int index=0; index<seeds.Count; index++) {

            IntVector3 seedPoint = (IntVector3)seeds [index];

            if (allVisitedVoxels.Contains (seedPoint)) {
                seeds.Remove (seedPoint);
                index--;
                continue;
            }

            ArrayList newVoxels = getBlob (mapData, stopCode, seedPoint);

            if (newVoxels.Count > 0) {
                detachedVoxels.AddRange (newVoxels);

            }

        }
        return detachedVoxels;
    }
开发者ID:Zulban,项目名称:viroid,代码行数:31,代码来源:MDPathfinder.cs

示例8: Start

    // Use this for initialization
    void Start()
    {
        // Get all waypoints and store transforms
        GameObject[] temp = GameObject.FindGameObjectsWithTag("Waypoint");
        Transform[] children = new Transform[temp.Length];

        // Sort the waypoints in ascending order
        for(int i = 0; i < temp.Length; i++)
        {
            int number = int.Parse(temp[i].name.Substring(8));

            children[number] = temp[i].transform;
        }

        indices = new ArrayList(); // Array of guard positions
        guards = new ArrayList(); // Array of guards

        // Place guards at waypoints without overlap
        for(int i = 0; i < numberOfGuards; i++)
        {
            int index = Random.Range(1, 15); // Choose waypoint on outer circle
            if(!indices.Contains(index) && index != 3 && index != 6 && index != 10 && index != 13)
            {
                // Instantiate guard and add index if no overlap
                indices.Add(index);
                GameObject g = (GameObject)Instantiate(guard, children[index].position, Quaternion.identity);
                g.GetComponent<Patroller>().position = index;
                guards.Add(g);
            }
            else
            {
                i--; // Decrement if ovelap
            }
        }
    }
开发者ID:noahdayan,项目名称:Modern-Computer-Games-Projects,代码行数:36,代码来源:Spawner.cs

示例9: unique

	public Hashtable unique(string elementValue, string elementID)
	{
		bool valid = true;
		
		ArrayList listNames = new ArrayList();
		listNames.Add("john");
		listNames.Add("david");
		listNames.Add("tim");
		listNames.Add("sheldon");
		listNames.Add("kim");
		
		if (elementValue.Trim() == string.Empty)
			valid = false;
		else
		{
			Regex objName = new Regex("^[ \t\r\n\v\f]*[a-zA-Z0-9_-]*[ \t\r\n\v\f]*$");
		
			if (!objName.IsMatch(elementValue))
				valid = false;
		}
		
		if (valid)
			if (listNames.Contains(elementValue.Trim().ToLower()))
				valid = false;
			
		Hashtable ht = new Hashtable();
		ht.Add("elementID", elementID);
		ht.Add("valid", valid);
		
		ExecBeforeLoad("ProcessValidationOnClient(response)");
		
		return ht;
	}
开发者ID:veraveramanolo,项目名称:power-show,代码行数:33,代码来源:cs_ServerValidator.aspx.cs

示例10: bttnChangeTribeInfo_Click

    protected void bttnChangeTribeInfo_Click(object sender, EventArgs e)
    {
        this.tribe.Tag = this.txtTag.Text;
        this.tribe.Name = this.txtName.Text;
        this.tribe.Description = this.txtDescription.Content;

        if (this.fileAvatar.HasFile)
        {
            ArrayList lstExtension = new ArrayList();
            lstExtension.Add(".jpg");
            lstExtension.Add(".gif");
            lstExtension.Add(".png");
            lstExtension.Add(".jpeg");
            string filename = fileAvatar.FileName;
            if (!lstExtension.Contains(Path.GetExtension(filename).ToLower()))
                this.lblAvatarError.Text = "Định dạng file ảnh phải là jpg";
            else if (!Functions.UploadImage(fileAvatar.FileContent, Server.MapPath("~/data/images/tribe/") + this.tribe.ID.ToString() + ".jpg"))
                this.lblAvatarError.Text = "File không đúng định dạng. Vui lòng thử lại với ảnh khác";
            else
                this.tribe.Avatar = true;
        }

        ISession session = (ISession)Context.Items[Constant.NHibernateSessionSign];
        session.Update(this.tribe);
        Response.Redirect("tribe.aspx?id=" + this.village.ID.ToString(), true);
    }
开发者ID:DF-thangld,项目名称:web_game,代码行数:26,代码来源:TribeProfile.ascx.cs

示例11: _TellTilesToFall

 // Coroutine that tells tiles above recently destroyed Tiles to fall down into their place
 IEnumerator _TellTilesToFall(ArrayList pointsToCheckForFall)
 {
     // Wait until the tile creation is done and no other tiles are falling
     while (pushInProgress && fallInProgressInt == 0)
         yield return new WaitForSeconds(1.0f);
     
     ArrayList visitedXPositions = new ArrayList();
     foreach (Vector2 currentPosVector in pointsToCheckForFall)
     {
         // If we haven't visited this column yet (We don't want to ask blocks to fall twice)
         if (!visitedXPositions.Contains(currentPosVector.x))
         {
             visitedXPositions.Add(currentPosVector.x);
             int currentXPos = (int)currentPosVector.x;
             int currentYPos = (int)currentPosVector.y;
             
             // Start at the currentYPos, and iterate upwards to all tiles in the array
             for (int incrementalY = currentYPos; incrementalY < gridHeight; incrementalY++)
             {
                 // Make sure testX and incrementalY are within the grid bounds
                 if ((currentXPos >= 0 && currentXPos <= gridWidth - 1) &&
                 (incrementalY >= 0 && incrementalY <= gridHeight - 1))
                 {
                     // Assuming tile still exists, tell it to fall
                     if (tileArray[currentXPos, incrementalY] != null)
                         tileArray[currentXPos, incrementalY].StartCoroutine(tileArray[currentXPos, incrementalY].Fall());
                 }
             }
         }
     }
     yield return null;
 }
开发者ID:TullyHanson,项目名称:Tiles,代码行数:33,代码来源:Grid.cs

示例12: findClosestWaypoint

    private Waypoints findClosestWaypoint()
    {
        ArrayList list = new ArrayList();
        Stack stack = new Stack();

        Vector3 carPosition = car.transform.position;
        float minDistance = float.MaxValue;
        Waypoints found = null;

        if(waypoints)
            stack.Push(waypoints);

        while(stack.Count > 0) {
            Waypoints actual = (Waypoints)stack.Pop();
            list.Add(actual);

            foreach(Waypoints w in actual.next) {
                if(!list.Contains(w))
                    stack.Push(w);
            }

            Vector3 waypointPosition = actual.transform.position;

            float distance = Vector3.Distance(carPosition, waypointPosition);

            if(distance < minDistance) {
                minDistance = distance;
                found = actual;
            }
        }

        return found;
    }
开发者ID:marrony,项目名称:ncar,代码行数:33,代码来源:IADriver.cs

示例13: BindHotelList

    public void BindHotelList()
    {
        MessageContent.InnerHtml = "";
        _hotelfacilitiesEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _hotelfacilitiesEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _hotelfacilitiesEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _hotelfacilitiesEntity.LogMessages.IpAddress = UserSession.Current.UserIP;

        _hotelfacilitiesEntity.HotelFacilitiesDBEntity = new List<HotelFacilitiesDBEntity>();
        HotelFacilitiesDBEntity hotelFacilitiesDBEntity = new HotelFacilitiesDBEntity();
        _hotelfacilitiesEntity.HotelFacilitiesDBEntity.Add(hotelFacilitiesDBEntity);
        hotelFacilitiesDBEntity.HotelID = hidHotelID.Value;
        DataSet dsResult = HotelFacilitiesBP.BindHotelList(_hotelfacilitiesEntity).QueryResult;

        if (dsResult.Tables.Count == 0 || dsResult.Tables[0].Rows.Count == 0)
        {
            return;
        }

        ArrayList chkList = new ArrayList();

        foreach (DataRow drRow in dsResult.Tables[0].Rows)
        {
            chkList.Add(drRow["FACILITIESCODE"].ToString());
        }

        for (int i = 0; i < dvChkList.Controls.Count; i++)
        {
            if (dvChkList.Controls[i].Controls.Count > 0)
            {
                CheckBoxList chbList = (CheckBoxList)dvChkList.Controls[i].Controls[0];
                foreach (ListItem li in chbList.Items)
                {
                    if (chkList.Contains(li.Value))
                    {
                        li.Selected = true;
                    }
                }
            }
        }
        UpdatePanel3.Update();
         //foreach (ListItem li in chkServiceList.Items)
         //{
         //    if (chkList.Contains(li.Value))
         //    {
         //       li.Selected = true;
         //    }
         //}

         //foreach (ListItem li in chkFacilitiesList.Items)
         //{
         //    if (chkList.Contains(li.Value))
         //    {
         //        li.Selected = true;
         //    }
         //}

        //UpdatePanel1.Update();
    }
开发者ID:WuziyiaoKingIris20140501,项目名称:KFC,代码行数:59,代码来源:FacilitiesHoteSetting.aspx.cs

示例14: IsStringArrayEqual

 // Just for string arrays.
 public static bool IsStringArrayEqual(ArrayList a1, ArrayList a2)
 {
     if (a1.Count != a2.Count) return false;
       foreach (string str in a1) {
         if (!a2.Contains(str)) return false;
       }
       return true;
 }
开发者ID:joshuacox,项目名称:dfo,代码行数:9,代码来源:Utils.cs

示例15: GetIntersection

 public static ArrayList GetIntersection(ArrayList src, ArrayList dst)
 {
     ArrayList intersectedlist = new ArrayList();
       foreach (object s in src) {
         if (dst.Contains(s)) intersectedlist.Add(s);
       }
       return intersectedlist;
 }
开发者ID:joshuacox,项目名称:dfo,代码行数:8,代码来源:Utils.cs


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