Пример #1
0
        //private Dictionary<int, MobileEntity> hashMat = new Dictionary<int, MobileEntity>();
        /// <summary>
        /// 判断元胞是否被占用了
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        internal bool IsOccupied(OxyzPointF opP)
        {
//			var mobileNode = base.First;
//			//update mobile on a lane one by one
//			while(mobileNode!=null) {
//				var mobile = mobileNode.Value;
//				//mobile is possibaly be deleted
//
//				if (mobile.IsMoved==true) {
//					//switch off
//					mobile.IsMoved = false;
//
//					foreach (var prevShap in mobile.PrevShape) {
//						int iKey = prevShap.GetHashCode();
//						if (this.hashMat.ContainsKey(iKey)==true) {
//							this.hashMat.Remove(iKey);
//						}
//
//					}
//
//					foreach (var Shap in mobile.Shape) {
//						int iKey = Shap.GetHashCode();
//						if (this.hashMat.ContainsKey(iKey)==false) {
//							this.hashMat.Add(iKey,mobile);
//						}
//					}
//
//				}
//				mobileNode = mobileNode.Next;
//			}
//
//			return this.hashMat.ContainsKey(opP.GetHashCode());

            //-----------------------------------------------------------
            var mobileNode = base.First;

            //update mobile on a lane one by one
            while (mobileNode != null)
            {
                var mobile = mobileNode.Value;
                //	mobile is possibaly deleted
                foreach (var Shap in mobile.Shape)
                {
                    if (Shap.Equals(opP))
                    {
                        return(true);
                    }
                }
                mobileNode = mobileNode.Next;
            }

            return(false);
            //-----------------------------------------------------------
        }