public void Refresh()
    {
        for (int i = 0; i < Rect.childCount; i++)
        {
            Transform tran = Rect.GetChild(i);
            UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
            if (item != null)
            {
                item.transform.GetChild(0).GetComponent <Text>().text = i.ToString();

                Items.Add(item);
                item.Init(this);
                item.Drag(StartValue + i * AddValue);
                if (item.v - 0.5 < 0.05f)
                {
                    Current = Items[i];
                }
            }
        }
        if (Rect.childCount < 5)
        {
            VMax = StartValue + 4 * AddValue;
        }
        else
        {
            VMax = StartValue + (Rect.childCount - 1) * AddValue;
        }
        if (MoveEnd != null)
        {
            MoveEnd(Current);
        }
    }
Esempio n. 2
0
 public void Refresh()
 {
     for (int i = 0; i < Rect.childCount; i++)
     {
         Transform tran = Rect.GetChild(i);
         UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
         if (item != null)
         {
             Items.Add(item);
             item.Init(this);
             item.Drag(StartValue + i * AddValue);
             if (Math.Abs(item.v - 0.5) < 0.05f)
             {
                 Current = Items[i];
                 Items[i].transform.Find("Name").gameObject.SetActive(true);
             }
             else
             {
                 Items[i].transform.Find("Name").gameObject.SetActive(false);
             }
         }
     }
     if (Rect.childCount < 5)
     {
         VMax = StartValue + 4 * AddValue;
     }
     else
     {
         VMax = StartValue + (Rect.childCount - 1) * AddValue;
     }
     if (MoveEnd != null)
     {
         MoveEnd(Current);
     }
 }
Esempio n. 3
0
    /// <summary>
    /// 产生对应的物体
    /// </summary>
    /// <param name="count">产生数量</param>
    /// <param name="status">1表示城市 2表示县城</param>
    void SpwanAllGameobject(int count, int status)
    {
        if (count <= 0)
        {
            return;
        }

        for (int i = 0; i < count; i++)
        {
            if (status == 1)
            {
                GameObject go = Instantiate(Resources.Load <GameObject>("Lobby/City"));
                go.transform.localScale       = Vector3.one;
                go.transform.localEulerAngles = Vector3.zero;
                go.transform.SetParent(Rect.transform);
                UI_Control_ScrollFlow_Item item = go.GetComponent <UI_Control_ScrollFlow_Item>();
                if (item != null)
                {
                    MahjongLobby_AH.Data.ParlorShowPanelData pspd = MahjongLobby_AH.GameData.Instance.ParlorShowPanelData;
                    MahjongLobby_AH.Data.SelectAreaPanelData sapd = MahjongLobby_AH.GameData.Instance.SelectAreaPanelData;
                    //更新该预置体的界面信息
                    item.GetComponent <Text>().text = pspd.listCityMessage[i].cityName;
                    item.iCityId = Convert.ToInt32(pspd.listCityMessage[i].cityId);
                    Items.Add(item);
                    item.Init(this);
                    item.Drag(StartValue + i * AddValue);
                    if (item.v - 0.5 < 0.05f)
                    {
                        Current = Items[i];
                    }
                }
            }
            else
            {
                GameObject go = Instantiate(Resources.Load <GameObject>("Lobby/County"));
                go.transform.localScale       = Vector3.one;
                go.transform.localEulerAngles = Vector3.zero;
                go.transform.SetParent(Rect.transform);
                UI_Control_ScrollFlow_Item item = go.GetComponent <UI_Control_ScrollFlow_Item>();
                if (item != null)
                {
                    MahjongLobby_AH.Data.SelectAreaPanelData sapd = MahjongLobby_AH.GameData.Instance.SelectAreaPanelData;
                    MahjongLobby_AH.Data.ParlorShowPanelData pspd = MahjongLobby_AH.GameData.Instance.ParlorShowPanelData;
                    //更新该预置体的界面信息
                    item.GetComponent <Text>().text = pspd.dicCountyMessage[sapd.iCityId][i].countyName;
                    item.iCountyId = Convert.ToInt32(pspd.dicCountyMessage[sapd.iCityId][i].countyId);
                    Items.Add(item);
                    item.Init(this);
                    item.Drag(StartValue + i * AddValue);
                    if (item.v - 0.5 < 0.05f)
                    {
                        Current = Items[i];
                    }
                }
            }
        }
    }
Esempio n. 4
0
    /// <summary>
    /// 获取指定的更新物体
    /// </summary>
    IEnumerator GetPointObject()
    {
        yield return(new WaitForSeconds(0.2f));

        ParlorShowPanelData pspd = GameData.Instance.ParlorShowPanelData;
        SelectAreaPanelData sapd = GameData.Instance.SelectAreaPanelData;

        if (status == 1)
        {
            int CityCount = transform.GetComponentsInChildren <UI_Control_ScrollFlow_Item>().Length;
            UI_Control_ScrollFlow_Item[] cityItem = new UI_Control_ScrollFlow_Item[CityCount];
            cityItem = transform.GetComponentsInChildren <UI_Control_ScrollFlow_Item>();
            for (int i = 0; i < CityCount; i++)
            {
                float y = cityItem[i].sv;
                if (0.9 < y && y < 1)
                {
                    pspd.temp_cc[0] = cityItem[i].iCityId;
                    pspd.iCityId[pspd.iStatus_AreaSeeting - 1] = cityItem[i].iCityId;

                    Debug.LogError("城市id:" + cityItem[i].iCityId);
                    break;
                }
            }

            //更新玩家对应的县的玩家
            UI_Control_ScrollFlow_Item[] temp = CountyMessage.transform.GetComponentsInChildren <UI_Control_ScrollFlow_Item>();
            int count = 0;
            if (pspd.dicCountyMessage.ContainsKey(sapd.iCityId))
            {
                count = pspd.dicCountyMessage[sapd.iCityId].Count;
            }
            CountyMessage.GetComponent <UI_Control_ScrollFlow>().Items.Clear();
            if (temp.Length > count)
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    if (i < count)
                    {
                        //更新该预置体的界面信息
                        temp[i].GetComponent <Text>().text = pspd.dicCountyMessage[sapd.iCityId][i].countyName;
                        temp[i].iCountyId = Convert.ToInt32(pspd.dicCountyMessage[sapd.iCityId][i].countyId);
                        CountyMessage.GetComponent <UI_Control_ScrollFlow>().Items.Add(temp[i]);
                        temp[i].Init_Num();
                        temp[i].Init(this);
                        temp[i].Drag(StartValue + i * AddValue);
                        if (temp[i].v - 0.5 < 0.05f)
                        {
                            CountyMessage.GetComponent <UI_Control_ScrollFlow>().Current = temp[i];
                        }
                    }
                    else
                    {
                        if (temp[i] != null)
                        {
                            Destroy(temp[i].gameObject);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    UI_Control_ScrollFlow_Item item = null;
                    if (i < temp.Length)
                    {
                        item = temp[i].GetComponent <UI_Control_ScrollFlow_Item>();
                        item.Init_Num();
                    }
                    else
                    {
                        GameObject go = Instantiate(Resources.Load <GameObject>("Lobby/County"));
                        go.transform.localScale       = Vector3.one;
                        go.transform.localEulerAngles = Vector3.zero;
                        go.transform.SetParent(CountyMessage.GetComponent <UI_Control_ScrollFlow>().Rect.transform);
                        item = go.GetComponent <UI_Control_ScrollFlow_Item>();
                    }

                    //更新该预置体的界面信息
                    item.GetComponent <Text>().text = pspd.dicCountyMessage[sapd.iCityId][i].countyName;
                    item.iCountyId = Convert.ToInt32(pspd.dicCountyMessage[sapd.iCityId][i].countyId);
                    CountyMessage.GetComponent <UI_Control_ScrollFlow>().Items.Add(item);
                    item.Init(this);
                    item.Drag(StartValue + i * AddValue);
                    if (item.v - 0.5 < 0.05f)
                    {
                        CountyMessage.GetComponent <UI_Control_ScrollFlow>().Current = item;
                    }
                }
            }
            CountyMessage.GetComponent <UI_Control_ScrollFlow>().Init();
            CountyMessage.GetComponent <UI_Control_ScrollFlow>().Refresh(1);
        }

        if (status == 2)
        {
            int CountyCount = transform.GetComponentsInChildren <UI_Control_ScrollFlow_Item>().Length;
            UI_Control_ScrollFlow_Item[] countyItem = transform.GetComponentsInChildren <UI_Control_ScrollFlow_Item>();
            for (int i = 0; i < CountyCount; i++)
            {
                float y = countyItem[i].sv;
                if (0.95f < y && y < 1.05f)
                {
                    pspd.temp_cc[1] = countyItem[i].iCountyId;
                    Debug.LogError("县城id:" + countyItem[i].iCountyId + ",名字:" + countyItem[i].GetComponent <Text>().text + ",位置:" + countyItem[i].transform.localPosition.y);
                    break;
                }
            }
        }
    }
    public void Refresh()
    {
        Debug.Log("===================Refresh=================");
        for (int i = 0; i < Rect.childCount; i++)
        {
            Transform tran = Rect.GetChild(i);
            if (ItemsOld.Contains(tran))
            {
                continue;
            }
            if (!tran.gameObject.activeInHierarchy)
            {
                continue;
            }

            UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
            if (item != null)
            {
                Items.Add(item);
                item.Init(this);
                item.Drag(StartValue + (Items.Count - 1) * AddValue);
                if (item.v - 0.5 < 0.05f)
                {
                    Current = item;
                }
            }
        }
        if (Items.Count < 5)
        {
            switch (Items.Count)
            {
            case 1:
            case 2:
                VMax = 0.7f;
                VMin = 0.3f;
                break;

            case 3:
                VMax = 0.9f;
                VMin = 0.1f;
                break;

            case 4:
                VMax = 1.1f;
                VMin = -0.1f;
                break;
            }
        }
        else
        {
            VMax = 0.9f + (Items.Count - 5) * AddValue;
            VMin = 0.1f;
        }
        if (MoveEnd != null)
        {
            MoveEnd(Current);
        }
        Check(1);
        for (int i = 0; i < Items.Count; i++)
        {
            Items[i].Refresh();
        }
        ItemsOld.Clear();
    }
Esempio n. 6
0
    public void Refresh()
    {
        Debug.Log("===================Refresh=================");
        for (int i = 0; i < Rect.childCount; i++)
        {
            Transform tran = Rect.GetChild(i);
            if (ItemsOld.Contains(tran))
            {
                continue;
            }
            if (!tran.gameObject.activeInHierarchy)
            {
                continue;
            }

            UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
            if (item != null)
            {
                Items.Add(item);
                item.Init(this);
                item.Drag(StartValue + (Items.Count - 1) * (1.0f / nCount));
                if (item.v - 0.5 < 0.05f)
                {
                    Current   = item;
                    firstitem = Current;
                    centerX   = Current.transform.localPosition.x;
                    height    = Current.GetComponent <RectTransform>().sizeDelta.y;

                    foreach (UI_Control_ScrollFlow_Item t in Items)
                    {
                        t.GetComponent <Image>().sprite =
                            t.GetComponent <UI_Control_ScrollFlow_Item>().Norimg;
                    }

                    Current.GetComponent <Image>().sprite =
                        Current.GetComponent <UI_Control_ScrollFlow_Item>().Preimg;
                    //item.GetComponent<uicontrolScrollViewItem>().Selected();
                }
                if (Items.Count == 2)
                {
                    spacingx = Mathf.Abs(Items[0].transform.localPosition.x - Items[1].transform.localPosition.x);
                    //Debug.LogError(spacingx);
                }
            }

            //Debug.Log(Items.Count.ToString() + "___" + item.name);
        }

        while (Items.Count < nCount)
        {
            m_nCount--;
        }

        VMax = 0.85f + (Items.Count - nCount) * (1.0f / nCount);
        VMin = 0.15f;


        Debug.Log("ddddd");
        if (MoveEnd != null)
        {
            MoveEnd(Current);
        }
        Check(1);
        for (int i = 0; i < Items.Count; i++)
        {
            Items[i].Refresh();
        }
        ItemsOld.Clear();
    }