private void SetPlayer1ConsumableItem([NotNull] object[] objects) { if (objects == null) { throw new ArgumentNullException(nameof(objects)); } List <ConsumableData> value = (List <ConsumableData>)objects[0]; ConsumableDatas = value; _list.SetVirtualAndLoop(); _list.itemRenderer = RenderListItem; _list.numItems = 1; _list.scrollPane.onScroll.Add(DoSpecialEffect); DoSpecialEffect(); scrollPane = _list.scrollPane; scrollPane.scrollStep = 93f; if (value.Count < 1) { _list.numItems = 1; _list.RefreshVirtualList(); } else { _list.numItems = value.Count; } { ConsumableData consumableData; ListExtend.TryGet <ConsumableData>(value, (int)((_list.GetFirstChildInView() + 1) % _list.numItems), out consumableData); _list.RefreshVirtualList(); } }
void changeHeroDetail() { choosedHeroIdx = (_hero_list.GetFirstChildInView() + 1) % _hero_list.numItems; _info.text = GameStaticData.getInstance().heroes [choosedHeroIdx].name; _desp.text = GameStaticData.getInstance().heroes [choosedHeroIdx].desp; _hero_list.ClearSelection(); _hero_list.GetChildAt(1).asButton.selected = true;; }
private void DoSpecialEffect() { float listCenter = list.scrollPane.posX + list.viewWidth / 2; for (int i = 0; i < list.numChildren; i++) { GObject item = list.GetChildAt(i); float itemCenter = item.x + item.width / 2; float itemWidth = item.width; float distance = Mathf.Abs(listCenter - itemCenter); if (distance < itemWidth) { float distanceRange = 1 + (1 - distance / itemWidth) * 0.2f; item.SetScale(distanceRange, distanceRange); } else { item.SetScale(1, 1); } } ShowIDInformation((list.GetFirstChildInView() + 3) % list.numItems); }
void DoSpecialEffect() { //change the scale according to the distance to middle float midX = _list.scrollPane.posX + _list.viewWidth / 2; int cnt = _list.numChildren; for (int i = 0; i < cnt; i++) { GObject obj = _list.GetChildAt(i); float dist = Mathf.Abs(midX - obj.x - obj.width / 2); if (dist > obj.width) //no intersection { obj.SetScale(1, 1); } else { float ss = 1 + (1 - dist / obj.width) * 0.24f; obj.SetScale(ss, ss); } } _mainView.GetChild("n3").text = "" + ((_list.GetFirstChildInView() + 1) % _list.numItems); }
void DoSpecialEffect() { float midX = _list.scrollPane.posX + _list.viewWidth / 2; int cnt = _list.numChildren; Debug.Log("cnt ---> " + cnt); for (int i = 0; i < cnt; i++) { GObject obj = _list.GetChildAt(i); float dist = Mathf.Abs(midX - obj.x - obj.width / 2); if (dist > obj.width) { obj.SetScale(1, 1); } else { float ss = 1 + (1 - dist / obj.width) * 0.24f; obj.SetScale(ss, ss); } } _mainView.GetChild("n3").text = "" + ((_list.GetFirstChildInView() + 1) % _list.numItems); }
int ReturnIndex() { return((roleList.GetFirstChildInView() + 2) % roleList.numItems); }
private void InitItem() { if (roleModel.rankData["type"] != null) { if ((int)roleModel.rankData["type"] == 3) { list.emptyStr = Tools.GetMessageById("31081"); } else { list.emptyStr = Tools.GetMessageById("31073"); } } list.itemRenderer = OnRender; list.SetVirtual(); list.onChangeNum.Add(this.CheckListNum); if (listData != null) { data = ModelManager.inst.rankModel.IsContainUser(listData, userModel.uid); index = (int)data["index"]; if (data["data"] != null) { Dictionary <string, object> data1 = (Dictionary <string, object>)data["data"]; // try{ // head1.url = Tools.SetLoaderButtonUrl(null,ModelUser.GetHeadUrl(((Dictionary<string, object>)data1["head"])["use"].ToString()),head1); // head2.url = ModelUser.GetHeadUrl(((Dictionary<string, object>)data1["head"])["use"].ToString()); Tools.SetLoaderButtonUrl(null, ModelUser.GetHeadUrl(((Dictionary <string, object>)data1["head"])["use"].ToString()), head1); Tools.SetLoaderButtonUrl(null, ModelUser.GetHeadUrl(((Dictionary <string, object>)data1["head"])["use"].ToString()), head2); // }catch(Exception e){ // Debug.Log (""); // } } list.scrollPane.onScroll.Add(() => { if (list.scrollPane.posY <= 0) { search_user_top.visible = false; top.visible = false; } else { top.visible = true; //search_user_botton.visible = false; } }); list.onTouchEnd.Add(() => { int scrollIndex = list.GetFirstChildInView(); if ((bool)data["isContain"]) { if (scrollIndex > 0) { top.visible = true; if (scrollIndex + 5 < index) { search_user_top.visible = false; search_user_botton.visible = true; } else if (scrollIndex + 5 >= index) { if (scrollIndex <= index) { search_user_top.visible = false; search_user_botton.visible = false; } else { search_user_top.visible = true; search_user_botton.visible = false; } } } else { top.visible = false; if (index > -1 && index < 6) { search_user_top.visible = false; search_user_botton.visible = false; } else { search_user_top.visible = false; search_user_botton.visible = true; } } } else { search_user_top.visible = false; search_user_botton.visible = false; if (scrollIndex > 0) { top.visible = true; } else { top.visible = false; } } }); if (listData.Count <= 5) { list.scrollPane.touchEffect = false; } else { if ((bool)data["isContain"]) { if (index > 6) { search_user_botton.visible = true; search_user_top.visible = false; } } } //list.itemRenderer = OnRender; //list.SetVirtual(); //list.numItems = listData.Count; //SetListCss(list, listData.ToArray(), 6); } //else //{ // //list.itemRenderer = OnRender; // //list.SetVirtual(); // list.numItems = 0; //} SetListCSS(list, listData.ToArray(), 6, true); }
public override void Init() { base.Init(); this.Create(Config.VIEW_ITEMCOLOR); // this.x = 0; // this.y = 70; userData = Tools.Clone((Dictionary <string, object>)ModelManager.inst.userModel.records ["body"]) as Dictionary <string, object>; cfgDa = Tools.Clone(DataManager.inst.body) as Dictionary <string, object>; object[] ship_show = (object[])DataManager.inst.systemSimple ["ship_show"]; bigImage = this.GetChild("n8").asLoader; shipInfo = this.GetChild("n33").asCom.GetChild("n0").asTextField; EffectManager.inst.EffectAlpha(this.GetChild("n0").asImage, 0); EffectManager.inst.EffectAlpha(this.GetChild("n1").asImage, 0); list = new List <object> (); // int index = 0; // foreach (string i in userData.Keys) // { // Dictionary<string,object> da = (Dictionary<string,object>)userData [i]; // da.Add ("id", i); // list.Add (da); // if (i == (string)ModelManager.inst.userModel.records ["use_body"]) // { // moveToIndex = index; // } // index++; // } this.GetChild("n18").asButton.text = Tools.GetMessageById("19891"); this.GetChild("n12").asTextField.text = Tools.GetMessageById("19892"); /* "s:int:0", */ // Tools.Sort (list, new string[]{"t:datetime:0" }); List <object> listt = new List <object> (); for (int j = 0; j < ship_show.Length; j++) { if (!userData.ContainsKey(ship_show [j].ToString())) { Dictionary <string, object> da = (Dictionary <string, object>)cfgDa [ship_show [j].ToString()]; da.Add("id", ship_show [j].ToString()); listt.Add(da); } else { Dictionary <string, object> das = (Dictionary <string, object>)userData [ship_show [j].ToString()]; das.Add("id", ship_show [j].ToString()); listt.Add(das); if (ship_show [j].ToString() == (string)ModelManager.inst.userModel.records ["use_body"]) { moveToIndex = j; } } } // Tools.Sort (listt, new string[]{ "id:string:0" }); for (int ii = 0; ii < listt.Count; ii++) { list.Add(listt [ii]); } SetUrlShow(list); l_list = this.GetChild("n2").asList; l_list.itemRenderer = List_Render; l_list.SetVirtual(); l_list.numItems = list.Count; l_list.onTouchEnd.Add(() => { int scrollIndex = l_list.GetFirstChildInView(); //Debug.Log(scrollIndex+" "+MaxNum); if (scrollIndex + 6 >= MaxNum || GetIndexNum() == "") { this.GetChild("n24").visible = false; } else { //Debug.Log("222222222222222"); //this.GetChild("n24").visible = true; } }); for (int iii = 0; iii < 7; iii++) { if (GetIndexNum().IndexOf(iii.ToString()) != -1) { this.GetChild("n24").visible = false; } } this.GetChild("n5").asButton.onTouchBegin.Add(OnTouchBegin); this.GetChild("n5").asButton.onTouchEnd.Add(OnTouchEnd); // TimerManager.inst.Add (0.01f, 0, OnTimerFunction); Stage.inst.onTouchMove.Add(OnTouchMove); this.GetChild("n11").asButton.onClick.Add(OnUnLockShip); this.GetChild("n18").asButton.touchable = false; this.GetChild("n19").asLoader.onClick.Add(() => { canPanel = true; SetRed(this.GetChild("n19").asLoader.data.ToString()); _changeID = this.GetChild("n19").asLoader.data.ToString(); SetUrlShow(list); listUpdate(); }); this.GetChild("n20").asLoader.onClick.Add(() => { canPanel = true; SetRed(this.GetChild("n20").asLoader.data.ToString()); _changeID = this.GetChild("n20").asLoader.data.ToString(); SetUrlShow(list); listUpdate(); }); this.GetChild("n21").asLoader.onClick.Add(() => { canPanel = true; SetRed(this.GetChild("n21").asLoader.data.ToString()); _changeID = this.GetChild("n21").asLoader.data.ToString(); SetUrlShow(list); listUpdate(); }); Btn_new = this.GetChild("n34").asButton; Btn_new.onClick.Add(() => { canPanel = true; //SetRed(this.GetChild("n21").asLoader.data.ToString()); //_changeID = this.GetChild("n21").asLoader.data.ToString(); l_list.ScrollToView(MaxNum); this.GetChild("n24").visible = false; listUpdate(); }); //AddGlobalListener(MainEvent.VIEWCOLOR,ViewColor); }
private void SearchRander(int index, GObject item) { GComponent comPhoto = item.asCom.GetChild("n1").asCom; GButton photo = comPhoto.GetChild("n0").asButton; GTextField name = item.asCom.GetChild("n3").asTextField; GTextField guild = item.asCom.GetChild("n4").asTextField; GObject rank = item.asCom.GetChild("n21"); GTextField rankScore = rank.asCom.GetChild("n2").asTextField; GLoader achieve = rank.asCom.GetChild("n1").asLoader; GTextField status = item.asCom.GetChild("n9").asTextField; GButton mask_btn = item.asCom.GetChild("n8").asButton; GButton btn_attention = item.asCom.GetChild("n7").asButton; GTextField attention_text = btn_attention.GetChild("title").asTextField; GLoader btn_image = btn_attention.asCom.GetChild("n1").asLoader; GObject reletion = item.asCom.GetChild("n2"); GButton more = item.asCom.GetChild("n10").asButton; GTextField lv = item.asCom.GetChild("n1").asCom.GetChild("n2").asTextField; GGroup itemBtn = item.asCom.GetChild("item").asGroup; //GImage bg = item.asCom.GetChild("n0").asImage; more.text = Tools.GetMessageById("13078"); bool isVisible = SetListCSS(item, listData.ToArray(), index); if (isVisible) { Dictionary <string, object> dc = (Dictionary <string, object>)listData[index]; more.visible = false; rankScore.visible = true; reletion.visible = false; rank.visible = true; int uid = (int)dc["uid"]; if (uid == -1) { // bg.visible = false; lv.visible = false; comPhoto.visible = false; name.visible = false; guild.visible = false; achieve.visible = false; status.visible = false; //mask_btn.visible = false; more.visible = true; btn_attention.visible = false; rank.visible = false; more.onClick.Add(() => { if (Convert.ToInt32(dc["type"]) == 1) { ViewManager.inst.ShowText(Tools.GetMessageById("13043")); } else { GetNearData(1, item); } }); } else { lv.visible = true; comPhoto.visible = true; name.visible = true; guild.visible = true; userModel.GetUnlcok(Config.UNLOCK_GUILD, guild); achieve.visible = true; status.visible = true; //mask_btn.visible = true; btn_attention.visible = true; more.visible = false; btn_attention.RemoveEventListeners(); btn_attention.onClick.Add(() => { //关注的实现 Dictionary <string, object> dd = new Dictionary <string, object>(); dd["fuid"] = dc["uid"]; NetHttp.inst.Send(NetBase.HTTP_FOLLOW, dd, (VoHttp vo) => { if ((bool)vo.data == true) { roleModel.AddAttentionFight(dc["uid"].ToString()); //ViewManager.inst.ShowText(Tools.GetMessageById("13045")); ((Dictionary <string, object>)listData[index])["if_follow"] = true; Tools.SetButtonBgAndColor(btn_attention, btnBgDo, textAttentiond, fontSize, textBtnColor, "", 0); btn_attention.touchable = false; // btn_image.url = Tools.GetResourceUrl("Image:btn_page3"); btn_attention.RemoveEventListeners(); } else { ViewManager.inst.ShowText(Tools.GetMessageById("13120")); } }); }); if ((bool)dc["if_black"]) {//是否拉黑 Tools.SetButtonBgAndColor(btn_attention, btnBgDo, textShieldd, fontSize, textBtnColor, "", 0); type = 1; btn_attention.touchable = false; } else if ((bool)dc["if_follow"]) { Tools.SetButtonBgAndColor(btn_attention, btnBgDo, textAttentiond, fontSize, textBtnColor, "", 0); type = 2; btn_attention.touchable = false; // btn_image.url = Tools.GetResourceUrl("Image:btn_page3"); } else { Tools.SetButtonBgAndColor(btn_attention, btnBgUp, textAttention, fontSize, textBtnColor, textBtnStrokeColor); btn_attention.touchable = true; } achieve.url = userModel.GetRankImg((int)dc["rank_score"]); status.text = Tools.GetNearDistance((int)dc["dis"]); mask_btn.RemoveEventListeners(); mask_btn.onClick.Add(() => { if (!more.visible) { roleModel.SetTempData(listData, new int[] { list.GetFirstChildInView(), tag_n, dataPreNum }); string uid_ = dc["uid"] + ""; if (!uid_.Equals(userModel.uid)) { this.DispatchGlobalEvent(new MainEvent(MainEvent.SHOW_USER, new object[] { null, uid_, roleModel.tab_CurSelect1, roleModel.tab_CurSelect2, roleModel.tab_CurSelect3 })); } else { ViewManager.inst.ShowText(Tools.GetMessageById("13106")); } } }); lv.text = dc["lv"].ToString(); string uname = dc["uname"] + ""; if (uname.Equals("")) { name.text = dc["uid"] + ""; } else { name.text = uname; } string dc_ = (string)dc["head_use"]; Tools.SetLoaderButtonUrl(photo, ModelUser.GetHeadUrl(dc_)); if (dc["guild_name"] == null) { guild.text = Tools.GetMessageById("19955"); } else { guild.text = dc["guild_name"] + ""; } rankScore.text = dc["rank_score"] + ""; } } else { btn_attention.visible = false; } }