예제 #1
0
        public List <TKPhysicalObj> GetObjectsInMap(Vector2 center, float range, TKPhysicalObj except)
        {
            List <TKPhysicalObj> ret = new List <TKPhysicalObj>();

            for (int i = 0; i < m_lstObjectInMap.Count; ++i)
            {
                TKPhysicalObj phy = m_lstObjectInMap[i];
                if (phy != except &&
                    phy.IsLiving &&
                    phy.CanCollided)
                {
                    Rect t = phy.GetCollideRect();
                    t.position += phy.Position;
                    float vx = Mathf.Abs(t.center.x - center.x);
                    float vy = Mathf.Abs(t.center.y - center.y);

                    float ux = vx - t.width / 2;
                    float uy = vy - t.height / 2;

                    if (ux * ux + uy * uy < range * range)
                    {
                        ret.Add(phy);
                    }
                }
            }
            return(ret);
        }
예제 #2
0
        public List <TKPhysicalObj> GetObjectsInMap(Rect rect, TKPhysicalObj except)
        {
            List <TKPhysicalObj> ret = new List <TKPhysicalObj>();

            for (int i = 0; i < m_lstObjectInMap.Count; ++i)
            {
                TKPhysicalObj phy = m_lstObjectInMap[i];
                if (phy != except &&
                    phy.IsLiving &&
                    phy.CanCollided)
                {
                    Rect t = phy.GetCollideRect();
                    t.position += phy.Position;
                    if (t.Overlaps(rect))
                    {
                        ret.Add(phy);
                    }
                }
            }
            return(ret);
        }