Пример #1
0
        public void Insert(ObjectGame obj)
        {
            Rectangle r = new Rectangle(obj.location.X, obj.location.Y, obj.bm.Width, obj.bm.Height);

            if (LeftBot == null)
            {
                CreateSubNode();
            }

            if (LeftTop != null && LeftTop.rec.Contains(r))
            {
                LeftTop.Insert(obj);
                return;
            }
            if (RightTop != null && RightTop.rec.Contains(r))
            {
                RightTop.Insert(obj);
                return;
            }
            if (LeftBot != null && LeftBot.rec.Contains(r))
            {
                LeftBot.Insert(obj);
                return;
            }
            if (RightBot != null && RightBot.rec.Contains(r))
            {
                RightBot.Insert(obj);
                return;
            }

            this.listObj.Add(obj);
        }