Пример #1
0
 IEnumerator SelectCor(SplatItem item)
 {
     open    = false;
     canMove = false;
     for (int i = 0; i < childs.Count; i++)
     {
         SplatItem splat = childs[i].GetComponent <SplatItem>();
         if (splat.active)
         {
             if (i == childs.Count - 1)
             {
                 yield return(splat.GoToRestCor(splat != item));
             }
             else
             {
                 StartCoroutine(splat.GoToRestCor(splat != item));
             }
         }
     }
     selected = item.gameObject;
     if (onSelected != null)
     {
         onSelected(item.GetText());
     }
     canMove = true;
 }
Пример #2
0
 public void Select(SplatItem item, bool discreet)
 {
     if (!open)
     {
         if (selected != null)
         {
             selected.gameObject.SetActive(false);
         }
         if (childs[0].gameObject.activeSelf)
         {
             childs[0].SetActive(false);
         }
         selected = item.gameObject;
         if (!discreet && onSelected != null)
         {
             onSelected(item.GetText());
         }
         item.gameObject.SetActive(true);
         return;
     }
     if (!canMove)
     {
         return;
     }
     if (open)
     {
         StartCoroutine(SelectCor(item));
     }
 }
Пример #3
0
 public void SetColor(Color color)
 {
     this.color = color;
     for (int i = 0; i < childs.Count; i++)
     {
         SplatItem splat = childs[i].GetComponent <SplatItem>();
         splat.color = color;
         splat.GetComponent <Image>().color = color;
     }
 }
Пример #4
0
 private SplatItem GetFurthestActiveChild()
 {
     for (int i = childs.Count - 1; i > 0; i--)
     {
         SplatItem sp = childs[i].GetComponent <SplatItem>();
         if (sp.active)
         {
             return(sp);
         }
     }
     return(null);
 }
Пример #5
0
    SplatItem CreateChild()
    {
        GameObject child = new GameObject("child_" + childs.Count);

        child.transform.SetParent(transform, false);
        SplatItem splat = child.AddComponent <SplatItem>();

        splat.host  = this;
        splat.size  = itemSize;
        splat.color = color;
        childs.Add(child);
        return(splat);
    }
Пример #6
0
        protected override void DoInitFromNode()
        {
            mNode = (CompareNode)node;
            int selectedAction = mNode.selectedAction;

            splat.UpdateList(ConvertActionsToString());

            string str = "";

            if (selectedAction != -1)
            {
                str = convertToString[selectedAction];
            }

            SplatItem item = splat.GetItemForText(str);

            if (item != null)
            {
                splat.Select(item);
            }
        }
Пример #7
0
    IEnumerator OpenCor()
    {
        open    = true;
        canMove = false;
        SplatItem furthest = GetFurthestActiveChild();

        for (int i = 0; i < childs.Count; i++)
        {
            SplatItem splat = childs[i].GetComponent <SplatItem>();
            if (splat.active)
            {
                if (splat == furthest)//this is the furthest child, wait till it arrived to continue
                {
                    yield return(splat.GoToDockCor());
                }
                else
                {
                    StartCoroutine(splat.GoToDockCor());
                    yield return(new WaitForSeconds(0.02f));
                }
            }
        }
        canMove = true;
    }
Пример #8
0
 public void Select(SplatItem item)
 {
     Select(item, false);
 }
Пример #9
0
    void UpdateFromList()
    {
        for (int i = 0; i < choices.Length; i++)
        {
            if (i < childs.Count)
            {
                //update child
                //if the selected if updated, call OnSelected
                SplatItem comp = childs[i].GetComponent <SplatItem>();
                comp.active = true;
                comp.SetText(choices[i]);
            }
            else
            {
                //create child
                SplatItem child = CreateChild();
                child.active = true;
                float radius = i < 6 ? 1 : i < 18 ? 2 : 3;

                float max = i < 6 ?
                            6 :
                            i < 18 ?
                            12 :
                            24;
                float lerp = i < 6 ?
                             i / max :
                             i < 18 ?
                             (i - 6) / max :
                             (i - 18) / max;

                /* float lerp = i < 6 ?
                 *           i / 6f :
                 *           i < 18 ?
                 *           (i - 6) / 12f :
                 *           (i - 18) / 24f;*/
                float pos = Mathf.Lerp(0f, Mathf.PI * 2, lerp);
                radius *= radiusMult;

                child.dockPos = new Vector2(Mathf.Cos(pos) * radius, Mathf.Sin(pos) * radius);
                child.SetText(choices[i]);
                if (i != 0)
                {
                    child.gameObject.SetActive(false);
                }
            }
        }
        for (int i = choices.Length; i < childs.Count; i++)
        {
            //if the selected is deactivated, call set the selected to 0 and call OnSelected
            //deactivate the ones in too many
            SplatItem splat = childs[i].GetComponent <SplatItem>();
            splat.active = false;
            splat.SetText("inactive");
            childs[i].SetActive(false);
            if (selected == childs[i])
            {
                selected = childs[0];
                if (onSelected != null)
                {
                    onSelected(childs[0].GetComponent <SplatItem>().GetText());
                }
            }
        }
    }