コード例 #1
0
ファイル: QuadTree.cs プロジェクト: suzuke/forge
        public void Update(IQuadTreeMonitor <T> monitor, Bound previousRegion, Bound currentRegion)
        {
            // update the stored monitor
            for (int i = 0; i < _monitors.Length; ++i)
            {
                if (ReferenceEquals(_monitors[i].Monitor, monitor))
                {
                    _monitors[i].Region = currentRegion;
                    break;
                }
            }

            // update the monitor
            for (int i = 0; i < _items.Length; ++i)
            {
                StoredItem item = _items[i];

                bool containedPrevious = previousRegion.Contains(item.Position);
                bool containedCurrent  = currentRegion.Contains(item.Position);

                // the monitor was previously interested but no longer is
                if (containedPrevious && containedCurrent == false)
                {
                    monitor.OnExit(item.Item);
                }

                // the monitor was not previous interested but now is
                else if (containedPrevious == false && containedCurrent)
                {
                    monitor.OnEnter(item.Item);
                }
            }
        }
コード例 #2
0
 public bool Add(T item)
 {
     if (Bound.Contains(item.Position))
     {
         if (m_childs.Length == 0)
         {
             if (Depth < MaxDepth)
             {
                 Subdivide();
             }
             else
             {
                 item.Node = this;
                 ArrayEx.Add(ref m_items, ref m_items_size, item);
                 return(true);
             }
         }
         for (int index = 0; index < m_childs.Length; index++)
         {
             if (m_childs[index].Add(item))
             {
                 return(true);
             }
         }
     }
     return(Parent?.Add(item) ?? false);
 }
コード例 #3
0
        /// <summary>
        /// 만약 Gfx의 rotate값이 0이 아닐 경우, RContains 함수가 정확합니다. 다만, 보시다시피, 비싼 계산을 요구합니다.
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public bool RContains(Point p)
        {
            Vector2 v  = Method2D.PtV(p);
            Point   RO = new Point(Pos.X + (ROrigin.X * Bound.Width) / Texture.Width, Pos.Y + (ROrigin.Y * Bound.Height) / Texture.Height); //실제 회전중심의 위치를 잡습니다.

            v = Vector2.Transform(v, Matrix2D.Rotate(RO, -Rotate));
            return(Bound.Contains(Method2D.VtP(v)));
        }
コード例 #4
0
        public bool RContains(Point p)//만약 Gfx의 rotate값이 0이 아닐 경우, RContains 함수가 정확합니다. 다만, 보시다시피, 비싼 계산을 요구합니다.
        {
            Vector2 v  = Method2D.PtV(p);
            Vector3 RO = new Vector3(Pos.X + (ROrigin.X * Bound.Width) / Texture.Width, Pos.Y + (ROrigin.Y * Bound.Height) / Texture.Height, 0);

            v = Vector2.Transform(v, Matrix.CreateTranslation(-RO) * Matrix.CreateRotationZ(-Rotate) * Matrix.CreateTranslation(RO));
            return(Bound.Contains(Method2D.VtP(v)));
        }
コード例 #5
0
ファイル: Button.cs プロジェクト: andreyVetlugin/MonoGame1
 public bool HandleMouseClick(Point coordinate)
 {
     if (Bound.Contains(coordinate))
     {
         RealiseButton();
         return(true);
     }
     return(false);
 }
コード例 #6
0
        public TileAttributes GetTileAttributes(Point point)
        {
            if (!Bound.Contains(point))
            {
                throw new ArgumentException(
                          string.Format("No tile exists at position {0}", point));
            }

            return(tiles[point.x, point.y].Attributes);
        }
コード例 #7
0
ファイル: QuadTree.cs プロジェクト: suzuke/forge
 /// <summary>
 /// Adds all of the items inside of this node that are contained within the given region to
 /// the given collection.
 /// </summary>
 /// <param name="region">The area to collect objects from.</param>
 /// <param name="storage">Where to store the collected objects.</param>
 public void CollectInto(Bound region, ICollection <T> storage)
 {
     for (int i = 0; i < _items.Length; ++i)
     {
         StoredItem item = _items[i];
         if (region.Contains(item.Position))
         {
             storage.Add(item.Item);
         }
     }
 }
コード例 #8
0
        public override bool IsVisible(PointF point)
        {
            bool result = base.IsVisible(point);

            if (!result && Bound.Contains(point))
            {
                Pen p = GetOutlinePen();
                return(Path.IsOutlineVisible(point, p));
            }

            return(result);
        }
コード例 #9
0
 public bool Update(T item)
 {
     if (ArrayEx.Contains(m_items, m_items_size, item))
     {
         if (Bound.Contains(item.Position))
         {
             return(true);
         }
         return(ArrayEx.Remove(m_items, ref m_items_size, item) && (Parent?.Add(item) ?? false));
     }
     return(Add(item));
 }
コード例 #10
0
ファイル: QuadTree.cs プロジェクト: wencong/RegionCombine
        public override void Receive(Renderer render)
        {
            if (!Bound.Contains(new Vector2(render.bounds.center.x, render.bounds.center.z)))
            {
                return;
            }

            if (!Contains(render))
            {
                m_lstGameObject.Add(render.gameObject);
                Quadtree.nReceivedCount++;
            }
        }
コード例 #11
0
ファイル: QuadTree.cs プロジェクト: suzuke/forge
        public void Add(IQuadTreeMonitor <T> monitor, Bound monitoredRegion)
        {
            _monitors.Add(new StoredMonitor(monitor, monitoredRegion));

            // check to see if the monitor is interested in any of our stored items
            for (int i = 0; i < _items.Length; ++i)
            {
                StoredItem item = _items[i];
                if (monitoredRegion.Contains(item.Position))
                {
                    monitor.OnEnter(item.Item);
                }
            }
        }
コード例 #12
0
ファイル: MTMeshData.cs プロジェクト: zcvdf/MightyTerrainMesh
 public void AddMesh(MTMeshHeader meshh)
 {
     if (mSubNode == null && Bound.Contains(meshh.Center))
     {
         MeshID = meshh.MeshID;
     }
     else if (mSubNode != null)
     {
         for (int i = 0; i < 4; ++i)
         {
             mSubNode[i].AddMesh(meshh);
         }
     }
 }
コード例 #13
0
 public void AddMesh(MTMeshHeader meshh)
 {
     if (m_SubNodes == null && Bound.Contains(meshh.Center + Offset))
     {
         MeshID = meshh.MeshID;
     }
     else if (m_SubNodes != null)
     {
         for (int i = 0; i < 4; ++i)
         {
             m_SubNodes[i].AddMesh(meshh);
         }
     }
 }
コード例 #14
0
ファイル: UQuadtree.cs プロジェクト: zs9024/uquadtree
    public override void Receive(IQtUserData userData)
    {
        if (!UQtAlgo.Intersects(Bound, userData))
        {
            return;
        }

        if (Bound.Contains(new Vector2(userData.GetCenter().x, userData.GetCenter().z)))
        {
            _ownedObjects.Add(userData);
        }
        else
        {
            _affectedObjects.Add(userData);
        }
    }
コード例 #15
0
 public bool Contains(T item)
 {
     if (Bound.Contains(item.Position))
     {
         if (m_childs.Length == 0)
         {
             return(ArrayEx.Contains(m_items, m_items_size, item));
         }
         for (int index = 0; index < m_childs.Length; index++)
         {
             if (m_childs[index].Contains(item))
             {
                 return(true);
             }
         }
     }
     return(Parent?.Contains(item) ?? false);
 }
コード例 #16
0
 public override bool IsVisible(PointF point)
 {
     if (Bound.Contains(point))
     {
         Pen p = Pen.Content;
         //线宽过小时不易选中,设置最小宽度为GraphicsTool.WidenWidth
         float minWdith = GraphicsTool.WidenWidth;
         float width    = p.Width;
         if (p.Width < minWdith)
         {
             p.Width = minWdith;
         }
         bool b2 = Path.IsVisible(point);
         p.Width = width;
         return(b2);
     }
     return(false);
 }
コード例 #17
0
 public bool Remove(T item)
 {
     if (Bound.Contains(item.Position))
     {
         if (m_childs.Length == 0 && ArrayEx.Remove(m_items, ref m_items_size, item))
         {
             item.Node = null;
             return(true);
         }
         for (int index = 0; index < m_childs.Length; index++)
         {
             if (m_childs[index].Remove(item))
             {
                 return(true);
             }
         }
     }
     return(Parent?.Remove(item) ?? false);
 }
コード例 #18
0
ファイル: QuadTree.cs プロジェクト: suzuke/forge
        public void Remove(IQuadTreeMonitor <T> monitor, Bound monitoredRegion)
        {
            // remove the stored monitor
            for (int i = 0; i < _monitors.Length; ++i)
            {
                if (ReferenceEquals(_monitors[i].Monitor, monitor))
                {
                    _monitors.Remove(i);
                    break;
                }
            }

            // remove all stored items from the monitor
            for (int i = 0; i < _items.Length; ++i)
            {
                StoredItem item = _items[i];

                if (monitoredRegion.Contains(item.Position))
                {
                    monitor.OnExit(item.Item);
                }
            }
        }
コード例 #19
0
    // Damage the entity, Invoke by ColonyRunner.cs. see it !
//    public virtual void OnDamaged(GameObject caster, float damge)
//    {
//        BaseData.m_Durability -= damge;
//
//        if (BaseData.m_Durability < -0.001f)
//            BaseData.m_Durability = -0.001f;
//
//
//        for (int i = 0; i < m_Soldiers.Count; i++)
//        {
//            m_Soldiers[i].ProtectedEntityDamaged(this, caster, damge);
//        }
//
//    }

    #region HELP_FUNC

//    private void SyncDura()
//    {
//        // Sync
//        CSMgCreator mgCreator = m_Creator as CSMgCreator;
//        if (mgCreator != null)
//        {
//            if (mgCreator.SimulatorMgr.ContainSimulator(ID))
//            {
//                CSSimulator csf = mgCreator.SimulatorMgr.GetSimulator(ID);
//                csf.SyncHP(DuraPercent);
//            }
//        }
//    }

    public bool ContainPoint(Vector3 pos)
    {
        return(Bound.Contains(pos));
    }
コード例 #20
0
 public bool Contains(Point p)
 {
     return(Bound.Contains(p));
 }
コード例 #21
0
ファイル: Label.cs プロジェクト: 20chan/Gridly
 public override bool IsHovering(Vector2 pos)
 {
     return(Bound.Contains(pos));
 }
コード例 #22
0
 public bool Contains(REMOPoint p)
 {
     return(Bound.Contains(p.ToPoint()));
 }