示例#1
0
 public void retrive_ex_fx(mario_bound b, ref List <mario_obj> objs)
 {
     if (nodes[0] != null)
     {
         int index = get_index(b);
         if (index != -1)
         {
             nodes[index].retrive_ex_fx(b, ref objs);
         }
         else
         {
             List <mario_bound> arr = bound.carve(b);
             for (int i = 0; i < arr.Count; ++i)
             {
                 index = get_index(arr[i]);
                 if (index != -1)
                 {
                     nodes[index].retrive_ex_fx(arr[i], ref objs);
                 }
             }
         }
     }
     objs.AddRange(objects[(int)mario_obj.mario_type.mt_block]);
     objs.AddRange(objects[(int)mario_obj.mario_type.mt_block1]);
 }
示例#2
0
 public void retrive_ex(mario_bound b, ref List <mario_obj> objs, int type)
 {
     if (nodes[0] != null)
     {
         int index = get_index(b);
         if (index != -1)
         {
             nodes[index].retrive_ex(b, ref objs, type);
         }
         else
         {
             List <mario_bound> arr = bound.carve(b);
             for (int i = 0; i < arr.Count; ++i)
             {
                 if (!arr[i].bs_yx)
                 {
                     continue;
                 }
                 index = get_index(arr[i]);
                 if (index != -1)
                 {
                     nodes[index].retrive_ex(arr[i], ref objs, type);
                 }
             }
         }
     }
     objs.AddRange(objects[type]);
 }
示例#3
0
    public int get_index(mario_bound b)
    {
        int  index    = -1;
        int  mid_x    = (bound.left + bound.right) / 2;
        int  mid_y    = (bound.top + bound.bottom) / 2;
        bool istop    = b.bottom >= mid_y && b.top < bound.top;
        bool isbottom = b.top < mid_y && b.bottom >= bound.bottom;
        bool isleft   = b.left >= bound.left && b.right < mid_x;
        bool isright  = b.right < bound.right && b.left >= mid_x;

        if (istop)
        {
            if (isleft)
            {
                index = 1;
            }
            else if (isright)
            {
                index = 0;
            }
        }
        else if (isbottom)
        {
            if (isleft)
            {
                index = 2;
            }
            else if (isright)
            {
                index = 3;
            }
        }
        return(index);
    }
示例#4
0
 public mario_qtree(mario_qtree p, int l, mario_bound b)
 {
     parent = p;
     level  = l;
     bound  = b;
     for (int i = 0; i < 4; ++i)
     {
         nodes.Add(null);
     }
     for (int i = (int)mario_obj.mario_type.mt_null; i < (int)mario_obj.mario_type.mt_end; ++i)
     {
         objects.Add(new List <mario_obj>());
     }
 }
示例#5
0
 public mario_qtree()
 {
     parent = null;
     level  = 1;
     bound  = new mario_bound(-20480, 143360, 143360, -20480);
     for (int i = 0; i < 4; ++i)
     {
         nodes.Add(null);
     }
     for (int i = (int)mario_obj.mario_type.mt_null; i < (int)mario_obj.mario_type.mt_end; ++i)
     {
         objects.Add(new List <mario_obj>());
     }
 }
示例#6
0
    public List <mario_bound> carve(mario_bound b)
    {
        int mid_x = (left + right) / 2;
        int mid_y = (top + bottom) / 2;

        if (bs == null)
        {
            bs = new List <mario_bound>();
            bs.Add(new mario_bound(0, 0, 0, 0, false));
            bs.Add(new mario_bound(0, 0, 0, 0, false));
            bs.Add(new mario_bound(0, 0, 0, 0, false));
            bs.Add(new mario_bound(0, 0, 0, 0, false));
        }
        if (mid_y <= b.top && mid_y > b.bottom)
        {
            if (mid_x > b.right)
            {
                bs[0].set_bound(b.left, b.right, b.top, mid_y, true);
                bs[1].set_bound(b.left, b.right, mid_y - 1, b.bottom, true);
                bs[2].bs_yx = false;
                bs[3].bs_yx = false;
            }
            else if (mid_x <= b.left)
            {
                bs[0].set_bound(b.left, b.right, b.top, mid_y, true);
                bs[1].set_bound(b.left, b.right, mid_y - 1, b.bottom, true);
                bs[2].bs_yx = false;
                bs[3].bs_yx = false;
            }
            else
            {
                bs[0].set_bound(b.left, mid_x - 1, b.top, mid_y, true);
                bs[1].set_bound(mid_x, b.right, b.top, mid_y, true);
                bs[2].set_bound(b.left, mid_x - 1, mid_y - 1, b.bottom, true);
                bs[3].set_bound(mid_x, b.right, mid_y - 1, b.bottom, true);
            }
        }
        else if (mid_y > b.top)
        {
            if (mid_x > b.right)
            {
            }
            else if (mid_x <= b.left)
            {
            }
            else
            {
                bs[0].set_bound(b.left, mid_x - 1, b.top, b.bottom, true);
                bs[1].set_bound(mid_x, b.right, b.top, b.bottom, true);
                bs[2].bs_yx = false;
                bs[3].bs_yx = false;
            }
        }
        else if (mid_y <= b.bottom)
        {
            if (mid_x > b.right)
            {
            }
            else if (mid_x <= b.left)
            {
            }
            else
            {
                bs[0].set_bound(b.left, mid_x - 1, b.top, b.bottom, true);
                bs[1].set_bound(mid_x, b.right, b.top, b.bottom, true);
                bs[2].bs_yx = false;
                bs[3].bs_yx = false;
            }
        }
        return(bs);
    }