Example #1
0
    public void SetupVariants(Variant[] vars)
    {
        if (!m_instance)
        {
            return;
        }

        int count = vars.Length;

        while (m_variants.Count < count)
        {
            Transform newPlace = Instantiate(m_gridInstance, m_gridParent);
            m_gridElements.Add(newPlace);
            DragNDropHandle newVariant = Instantiate(m_instance, transform);
            newVariant.SetModule(m_module);
            m_variants.Add(newVariant);
        }

        for (int i = count; i < m_variants.Count; ++i)
        {
            m_variants[i].gameObject.SetActive(false);
        }

        m_vars = ShuffleList(vars);

        StartCoroutine(InitValues());
    }
Example #2
0
 public ArrangeCell TryAddToCell(DragNDropHandle handle)
 {
     foreach (var cell in m_cells)
     {
         if (cell.CheckFalling(handle))
         {
             cell.SwapHandles(handle);
             return(cell);
         }
     }
     return(null);
 }
Example #3
0
    public DragNDropHandle SwapHandles(DragNDropHandle newHandle)
    {
        DragNDropHandle oldHandle = m_item;

        if (oldHandle)
        {
            oldHandle.ResetCell();
            oldHandle.SetPos(newHandle.GetStartPos());
        }

        m_item = newHandle;
        RectTransform rect = transform as RectTransform;

        m_item.transform.position = transform.position;// + new Vector3(rect.rect.center.x, rect.rect.center.y);

        return(oldHandle);
    }
Example #4
0
    public bool CheckFalling(DragNDropHandle handle)
    {
        RectTransform rect = transform as RectTransform;

        return(RectTransformUtility.RectangleContainsScreenPoint(rect, handle.transform.position));
    }
Example #5
0
 public void ResetItem()
 {
     m_item = null;
 }