示例#1
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);
     }
 }
    public void Update()
    {
        if (_anim)
        {
            CurrentV = Time.deltaTime * _anim_speed * Vk;
            VT       = Vtotal + CurrentV;
            if (Vk > 0 && VT >= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            if (Vk < 0 && VT <= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            //==============
            for (int i = 0; i < Items.Count; i++)
            {
                Items[i].Drag(CurrentV);
                if (Items[i].positonValue - 0.5 < 0.05f)
                {
                    Current = Items[i];
                }
            }
            Check(CurrentV);
            Vtotal = VT;

            if (!_anim)
            {
                if (MoveEnd != null)
                {
                    MoveEnd(Current);
                }
            }
        }
    }
 private void MoveOverEvent(UI_Control_ScrollFlow_Item t)
 {
     //上面参数框里MoveOverEvent(UI_Control_ScrollFlow_Item t)
     //t表示滑动后或者直接点选的对象 ,假如大家在做的时候 每个Item上有
     //代码绑定 可以通过t.GetComponent<>()来查找 并操作。
     Debug.Log("你要做的事情");
 }
    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);
        }
    }
示例#5
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];
                    }
                }
            }
        }
    }
示例#6
0
 //将合成品放入面板
 private void AddPanel(int id)
 {
     if (LoadObjctDateConfig.Instance.BaseAtrributes.ContainsKey(id))
     {
         GameObject _oilItem = GameObject.Instantiate(SEOilItem) as GameObject;
         _oilItem.transform.SetParent(OilList);
         _oilItem.transform.localPosition = new Vector3(0, 65.75f, 0);
         UI_Control_ScrollFlow_Item _item = _oilItem.GetComponent <UI_Control_ScrollFlow_Item>();
         _item.ID = id;
     }
 }
 private void MoveOverEvent(UI_Control_ScrollFlow_Item t)
 {
     //上面参数框里MoveOverEvent(UI_Control_ScrollFlow_Item t)
     //t表示滑动后或者直接点选的对象 ,假如大家在做的时候 每个Item上有
     //代码绑定 可以通过t.GetComponent<>()来查找 并操作。
     Debug.Log("你要做的事情");
     foreach (UI_Control_ScrollFlow_Item temp in UI_Control_ScrollFlow.instance.Items)
     {
         temp.gameObject.GetComponent <Image>().sprite = temp.GetComponent <UI_Control_ScrollFlow_Item>().Norimg;
     }
     t.GetComponent <Image>().sprite = t.GetComponent <UI_Control_ScrollFlow_Item>().Preimg;
 }
示例#8
0
    void Update()
    {
        if (_anim)
        {
            CurrentV = Time.deltaTime * _anim_speed * Vk;
            VT       = Vtotal + CurrentV;
            if (Vk > 0 && VT >= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            if (Vk < 0 && VT <= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            //==============
            for (int i = 0; i < Items.Count; i++)
            {
                Items[i].Drag(CurrentV);
                if (Items[i].v - 0.5 < 0.05f)
                {
                    Current = Items[i];
                    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;
                }
            }
            Check(CurrentV);
            Vtotal = VT;


            if (!_anim)
            {
                if (MoveEnd != null)
                {
                    MoveEnd(Current);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            GenerateBtn();
        }
    }
示例#9
0
 public void OnPointerClick(PointerEventData eventData)
 {
     Debug.Log("OnPointerClick:" + eventData.pointerPressRaycast.gameObject);
     if (add_vect.sqrMagnitude <= 1)
     {
         Debug.Log("============OnPointerClickOK============");
         UI_Control_ScrollFlow_Item script = eventData.pointerPressRaycast.gameObject.GetComponent <UI_Control_ScrollFlow_Item>();
         if (script != null)
         {
             float k = script.v;
             k = 0.5f - k;
             AnimToEnd(k);
         }
     }
 }
示例#10
0
    void Update()
    {
        if (_anim)
        {
            CurrentV = Time.deltaTime * _anim_speed * Vk;
            VT       = Vtotal + CurrentV;
            if (Vk > 0 && VT >= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            if (Vk < 0 && VT <= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            //==============
            for (int i = 0; i < Items.Count; i++)
            {
                Items[i].Drag(CurrentV);
                if (Math.Abs(Items[i].v - 0.5) < 0.05f)
                {
                    Current = Items[i];
                    Current.transform.Find("Name").gameObject.SetActive(true);
                    if (Need != null)
                    {
                        RefreshNeedItems();
                    }
                }
                else
                {
                    Items[i].transform.Find("Name").gameObject.SetActive(false);
                }
            }
            Check(CurrentV);
            Vtotal = VT;


            if (!_anim)
            {
                if (MoveEnd != null)
                {
                    MoveEnd(Current);
                }
            }
        }
    }
示例#11
0
        //初始化要加工的精油的面板信息,只初始化一次
        private void InitOilPanel()
        {
            int _id = 301;
            UI_Control_ScrollFlow ui_control = OilList.GetComponent <UI_Control_ScrollFlow>();

            while (LoadObjctDateConfig.Instance.GetAtrribute(_id) != null)
            {
                GameObject oilItem = GameObject.Instantiate(POilItem) as GameObject;
                oilItem.transform.SetParent(OilList);
                oilItem.transform.localPosition = new Vector3(0, 23.5f, 0);
                UI_Control_ScrollFlow_Item item = oilItem.GetComponent <UI_Control_ScrollFlow_Item>();
                item.ID = _id;
                _id++;
            }
            OilList.GetChild(OilList.childCount - 2).SetSiblingIndex(0);
            OilList.GetChild(OilList.childCount - 1).SetSiblingIndex(1);
            ui_control.Refresh();
        }
示例#12
0
 //初始化要合成的精油(计算数量)
 private void InitOils()
 {
     for (int i = 0; i < OilList.childCount; i++)
     {
         Transform tran = OilList.GetChild(i);
         UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
         if (item != null && item.NeedIds.Count > 0)
         {
             int needId = item.NeedIds[0].id;
             int count  = 0;
             if (Farm_Game_StoreInfoModel.storage.Results.ContainsKey(needId))
             {
                 Result result = Farm_Game_StoreInfoModel.storage.Results[needId];
                 count      = result.ObjectNum / result.UpGradeToOilNum;
                 item.Count = count;
             }
             tran.Find("Count").GetComponent <Text>().text = "x " + count.ToString();
         }
     }
 }
示例#13
0
 //初始化要合成的高级精油列表
 private void InitSOilList()
 {
     for (int i = 0; i < OilList.childCount; i++)
     {
         Transform tran = OilList.GetChild(i);
         UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
         if (item != null && item.NeedIds.Count > 0)
         {
             int needId = item.NeedIds[0].id;
             int count  = 0;
             if (Farm_Game_StoreInfoModel.storage.Oils.ContainsKey(needId))
             {
                 Oil poil = Farm_Game_StoreInfoModel.storage.Oils[needId];
                 count = poil.ObjectNum / poil.CombinCount;
             }
             item.Count = count;
             tran.Find("Count").GetComponent <Text>().text = "x " + item.Count.ToString();
         }
     }
 }
示例#14
0
    void Update()
    {
        if (Current != null)
        {
            UIMovableData tmpData = Current.gameObject.GetComponent <UIMovableData>();
            t.text = tmpData.UIdata.activity_theme + "\n" + "宝贝数量:" + tmpData.UIdata.amount + "\n" + "活动地点:" + tmpData.UIdata.activity_site + "\n" + "活动时间:" + tmpData.UIdata.begin_time;
        }
        if (_anim)
        {
            CurrentV = Time.deltaTime * _anim_speed * Vk;
            VT       = Vtotal + CurrentV;
            if (Vk > 0 && VT >= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            if (Vk < 0 && VT <= AddV)
            {
                _anim = false; CurrentV = AddV - Vtotal;
            }
            //==============
            for (int i = 0; i < Items.Count; i++)
            {
                Items[i].Drag(CurrentV);
                if (Items[i].v - 0.5 < 0.05f)
                {
                    Current = Items[i];
                }
            }
            Check(CurrentV);
            Vtotal = VT;


            if (!_anim)
            {
                if (MoveEnd != null)
                {
                    MoveEnd(Current);
                }
            }
        }
    }
示例#15
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (add_vect.sqrMagnitude <= 1)
        {
            UI_Control_ScrollFlow_Item script = eventData.pointerPressRaycast.gameObject.GetComponent <UI_Control_ScrollFlow_Item>();
            if (script != null)
            {
                float k = script.v;
                k = 0.5f - k;
                AnimToEnd(k);
                //script.GetComponent<LSW_ScrollViewItem>().Selected();
                Debug.Log(script.gameObject.transform.Find("Text").GetComponent <Text>().text);

                foreach (UI_Control_ScrollFlow_Item temp in Items)
                {
                    temp.gameObject.GetComponent <Image>().sprite =
                        temp.GetComponent <UI_Control_ScrollFlow_Item>().Norimg;
                }
                script.GetComponent <Image>().sprite =
                    script.GetComponent <UI_Control_ScrollFlow_Item>().Preimg;
            }
        }
    }
示例#16
0
        //初始化要合成的高级精油列表
        private void InitSOilList()
        {
            for (int i = 0; i < OilList.childCount; i++)
            {
                Transform tran = OilList.GetChild(i);
                UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
                if (item != null)
                {
                    List <NeedClass> needIds = item.NeedIds;
                    if (needIds.Count > 0)
                    {
                        int        min = 0;
                        BaseObject bo  = Farm_Game_StoreInfoModel.Instance.GetData(needIds[0].id);
                        if (bo != null)
                        {
                            min = bo.ObjectNum;
                        }

                        for (int j = 0; j < needIds.Count; j++)
                        {
                            BaseObject _bo = Farm_Game_StoreInfoModel.Instance.GetData(needIds[j].id);
                            if (_bo != null)
                            {
                                min = min < bo.ObjectNum ?min:bo.ObjectNum;
                            }
                            if (min == 0)
                            {
                                break;
                            }
                        }
                        item.Count = min;
                    }
                    tran.Find("Count").GetComponent <Text>().text = "x " + item.Count.ToString();
                }
            }
        }
示例#17
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;
                }
            }
        }
    }
示例#18
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();
    }
示例#19
0
 public void ToLaster(UI_Control_ScrollFlow_Item item)
 {
     item.v = Items[Items.Count - 1].v + AddValue;
     Items.Remove(item);
     Items.Add(item);
 }
    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();
    }