public TypeSelectorDropdown( OnSelectedCallback callback, PathSelector selector = null, Predicate <Type> typeFilter = null ) : base(new AdvancedDropdownState()) { this.callback = callback; this.selector = selector ?? SelectPath; this.typeFilter = typeFilter; }
public void Init(IList datas, string prefabname, int currindex, int thewidth = 0, int theheight = 0, OnSelectedCallback selectedcallback = null) { CurrentIndex = currindex; DataPravider = datas; OnSelected = selectedcallback; if (HaveNotInit) { ItemPrefab = Resources.Load(prefabname) as GameObject; Item0 = NGUITools.AddChild(gameObject, ItemPrefab); Item1 = NGUITools.AddChild(gameObject, ItemPrefab); Item2 = NGUITools.AddChild(gameObject, ItemPrefab); Items = new List<GameObject>(); Items.Add(Item0); Items.Add(Item1); Items.Add(Item2); OldXList = new List<float>(); OldYList = new List<float>(); StartXList = new List<float>(); OldXList.Add(0); OldXList.Add(0); OldXList.Add(0); OldYList.Add(0); OldYList.Add(0); OldYList.Add(0); StartXList.Add(0); StartXList.Add(0); StartXList.Add(0); TheWidth = thewidth; TheHeight = theheight; baseX1 = gameObject.transform.localPosition.x - TheWidth / 2; baseX2 = baseX1 + TheWidth; CenterX = Screen.width/2; CenterY = Screen.height/2; baseY1 = gameObject.transform.localPosition.y - TheHeight / 2; baseY2 = baseY1 + TheHeight; baseX1 *= CameraAdjuster.CameraScale; baseX2 *= CameraAdjuster.CameraScale; baseY1 *= CameraAdjuster.CameraScale; baseY2 *= CameraAdjuster.CameraScale; moveFlag = TheWidth/3; HaveNotInit = false; } ShowItem(0); }
public void Init(IList datas, string prefabname, int thewidth, int theheight, int itemwidth, int itemheight, OnSelectedCallback selectedcallback = null) { dataPravider = datas; onSelected = selectedcallback; if (haveNotInit) { itemBox = transform.FindChild("Container").gameObject; itemBox.GetComponent<UIWidget>(); itemPrefab = Resources.Load(prefabname) as GameObject; itemHeight = itemheight; items = new List<GameObject>(); haveNotInit = false; } while (items.Count < dataPravider.Count) { items.Add(NGUITools.AddChild(itemBox, itemPrefab)); var theitem = items[items.Count - 1].GetComponent<KxItemRender>(); theitem.OnSelected += OnSelecteHandler; theitem.InitItem(); } for (int j = 0; j < items.Count; j++) { items[j].SetActive(false); } int i; for (i = 0; i < dataPravider.Count; i++) { items[i].SetActive(true); var theitem = items[i].GetComponent<KxItemRender>(); theitem.ItemIndex = i; theitem.SetData(dataPravider[i]); items[i].transform.localPosition = new Vector3(0, 0 - itemHeight * i, 0); } }
public void Init(IList datas, string prefabname, int thewidth, int theheight, int itemwidth, int itemheight, OnSelectedCallback selectedcallback = null, bool playeffect = true, bool showupbutton = false) { dataPravider = datas; NeedPlayEffect = playeffect; //PopTextManager.PopTip("Stage count " + dataPravider.Count); OnSelected = selectedcallback; if (haveNotInit) { itemBox = transform.FindChild("Panel/Container").gameObject; ClipPanel = transform.FindChild("Panel").gameObject; ClickBox = transform.FindChild("Panel/Container click").gameObject; var cld = ClickBox.GetComponent<BoxCollider>(); cld.size = new Vector3(thewidth, theheight, 0); BgClickEventListener = UIEventListener.Get(ClickBox); BgClickEventListener.onPress += OnPressHandler; itemBox.GetComponent<UIWidget>(); itemPrefab = Resources.Load(prefabname) as GameObject; var pn = ClipPanel.GetComponent<UIPanel>(); pn.baseClipRegion = new Vector4(0, 0, thewidth, theheight); if (showupbutton) { UpButton = transform.FindChild("Button up").gameObject; UpButton.transform.localPosition = new Vector3(thewidth / 2 - 90, -theheight / 2 + 20, 0); UpEventListener = UIEventListener.Get(UpButton); UpEventListener.onClick += UpClickHandler; UpButton.SetActive(false); } theWidth = thewidth; theHeight = theheight; itemHeight = itemheight; maxItemCount = theHeight * 3 / itemHeight; Items = new List<GameObject>(); baseX1 = gameObject.transform.localPosition.x - theWidth / 2; baseX2 = baseX1 + theWidth; centerX = Screen.width / 2; centerY = Screen.height / 2; baseY1 = gameObject.transform.localPosition.y - theHeight / 2; baseY2 = baseY1 + theHeight; baseX1 *= CameraAdjuster.CameraScale; baseX2 *= CameraAdjuster.CameraScale; baseY1 *= CameraAdjuster.CameraScale; baseY2 *= CameraAdjuster.CameraScale; maxY = theHeight / 2 - itemHeight / 2; minItemY = baseY1 - theHeight; maxItemY = baseY2 + theHeight; haveNotInit = false; } while (Items.Count < maxItemCount && Items.Count < dataPravider.Count) { Items.Add(NGUITools.AddChild(itemBox, itemPrefab)); var theitem = Items[Items.Count - 1].GetComponent<KxItemRender>(); theitem.OnSelected += OnSelecteHandler; theitem.OnPress += OnPressHandler; theitem.ItemHeight = itemHeight; theitem.ItemWidth = itemwidth; theitem.OnResize += OnResizeHandler; theitem.InitItem(); } for (int j = 0; j < Items.Count; j++) { Items[j].SetActive(false); } int i; for (i = 0; i < Items.Count && i < dataPravider.Count; i++) { Items[i].SetActive(true); var theitem = Items[i].GetComponent<KxItemRender>(); theitem.ItemIndex = i; EndDataIndex = i; theitem.SetData(dataPravider[i]); Items[i].transform.localPosition = playeffect ? new Vector3(thewidth, maxY - theitem.ItemHeight * i, 0) : new Vector3(0, maxY - theitem.ItemHeight * i, 0); } totalHeight = itemHeight*dataPravider.Count; StartIndex = 0; StartDataIndex = 0; if (NeedPlayEffect) itemBox.transform.localPosition = new Vector3(0, 0, 0); if (gameObject.activeInHierarchy) { ShowItems(); } //PopTextManager.PopTip("data count " + dataPravider.Count); }
public void Init(IList datas, string prefabname, int thewidth, int theheight, int itemwidth, int itemheight, OnSelectedCallback selectedcallback = null) { dataPravider = datas; if (datas == null || datas.Count == 0) { gameObject.SetActive(false); return; } gameObject.SetActive(true); //PopTextManager.PopTip("Stage count " + dataPravider.Count); OnSelected = selectedcallback; if (haveNotInit) { itemBox = transform.FindChild("Container").gameObject; selectBox = transform.FindChild("Container/Sprite select").gameObject; var selectbox = selectBox.GetComponent<UISprite>(); selectbox.width = 114; selectbox.height = 114; itemBox.GetComponent<UIWidget>(); itemPrefab = Resources.Load(prefabname) as GameObject; theWidth = thewidth; theHeight = theheight; itemWidth = itemwidth; maxItemCount = theWidth * 3 / itemWidth; Items = new List<GameObject>(); baseX1 = gameObject.transform.localPosition.x - theWidth / 2; baseX2 = baseX1 + theWidth; centerX = Screen.width / 2; centerY = Screen.height / 2; baseY1 = gameObject.transform.localPosition.y - theHeight / 2; baseY2 = baseY1 + theHeight; baseX1 *= CameraAdjuster.CameraScale; baseX2 *= CameraAdjuster.CameraScale; baseY1 *= CameraAdjuster.CameraScale; baseY2 *= CameraAdjuster.CameraScale; minX = - theWidth / 2 + itemWidth / 2; maxX = theWidth/2 - itemWidth/2; minItemX = baseX1 - theWidth; maxItemX = baseX2 + theWidth; haveNotInit = false; } while (Items.Count < maxItemCount && Items.Count < dataPravider.Count) { Items.Add(NGUITools.AddChild(itemBox, itemPrefab)); var theitem = Items[Items.Count - 1].GetComponent<KxItemRender>(); theitem.OnSelected += OnSelecteHandler; theitem.InitItem(); } //SystemInfo.deviceModel for (int j = 0; j < Items.Count; j++) { Items[j].SetActive(false); } int i; for (i = 0; i < Items.Count && i < dataPravider.Count; i++) { Items[i].SetActive(true); var theitem = Items[i].GetComponent<KxItemRender>(); theitem.ItemIndex = i; EndDataIndex = i; theitem.SetData(dataPravider[i]); Items[i].transform.localPosition = new Vector3(minX + itemWidth * i, 0, 0); } StartIndex = 0; StartDataIndex = 0; //PopTextManager.PopTip("data count " + dataPravider.Count); if (Items.Count > 0) { OnSelecteHandler(Items[0]); } }
public TypeSelectorDropdown(OnSelectedCallback callback, PathSelector selector = null) : base(new AdvancedDropdownState()) { this.callback = callback; this.selector = selector ?? SelectPath; }
public int SetData(QusetMsgInfo theinfo, OnSelectedCallback selectfunc = null) { if (BgSprite == null) { BgSprite = transform.FindChild("Sprite bg").gameObject; TitleLabel = transform.FindChild("Label title").gameObject; GetLabel = transform.FindChild("Label gift").gameObject; RewardItem = transform.FindChild("SignItem").gameObject; GetButton = transform.FindChild("Button").gameObject; BtnBgScript = transform.FindChild("Button/Background").gameObject; BtnLabel = transform.FindChild("Button/Label").gameObject; ButtonUIEventListener = UIEventListener.Get(GetButton); ButtonUIEventListener.onClick += ClickBtnHandler; GotoUIEventListener = UIEventListener.Get(TitleLabel); GotoUIEventListener.onClick += GotoBtnHandler; } OnSelected = selectfunc; questInfo = theinfo; questTemp = SystemModelLocator.Instance.QuestTemplates.QuestTmpls[questInfo.Id]; var lb = TitleLabel.GetComponent<UILabel>(); lb.text = questTemp.Desc; //0未完成 1已完成未领取 2 已领取 if (questInfo.Status == 0) { BgSprite.SetActive(true); GetLabel.SetActive(true); RewardItem.SetActive(true); var item = RewardItem.GetComponent<SignItemControl>(); item.SetData(questTemp.RewardId, false, false, SelectHandler); RewardTemplate = item.RewardTemplate; GetButton.SetActive(false); return 0; } else if (questInfo.Status == 1) { BgSprite.SetActive(true); GetLabel.SetActive(false); RewardItem.SetActive(false); GetButton.SetActive(true); lb = BtnLabel.GetComponent<UILabel>(); lb.text = "领取"; lb.color = new Color(250,230,0); var btn = GetButton.GetComponent<UIButton>(); btn.enabled = true; BtnBgScript.SetActive(true); // var sp = BtnBgScript.GetComponent<UISprite>(); // sp.color = new Color(255, 255, 255); return 0; } else { BgSprite.SetActive(false); GetLabel.SetActive(false); RewardItem.SetActive(false); GetButton.SetActive(true); lb = BtnLabel.GetComponent<UILabel>(); lb.text = "已领取"; lb.color = new Color(100, 100, 100); var btn = GetButton.GetComponent<UIButton>(); btn.enabled = false; BtnBgScript.SetActive(false); return 1; } }
private void OnSelect() { IsSelected = true; OnSelectedCallback?.Invoke(); }
//奖励的id,是否已经签到,是否可以选择 public void SetData(int rewardid, bool havesign, bool canselect, OnSelectedCallback selectfunc = null) { RewardId = rewardid; HaveSign = havesign; CanSelect = canselect; OnSelected = selectfunc; Debug.Log("rewardid:" + rewardid); //PopTextManager.PopTip("rewardid:" + rewardid); RewardTemplate = SystemModelLocator.Instance.RewardTemplates.RewardTmpls[rewardid]; if (RewardTemplate.RewardType == SIGN_REWARD_TYPE_HERO) { var tem = HeroModelLocator.Instance.GetHeroByTemplateId(RewardTemplate.RewardTempId); Name = tem.Name; Count = 1; } else if (RewardTemplate.RewardType == SIGN_REWARD_TYPE_ITEM) { Name = ItemModeLocator.Instance.GetName(RewardTemplate.RewardTempId); Count = 1; } else { Name = MailConstant.GetCurrencyNameById(RewardTemplate.RewardTempId); Count = RewardTemplate.RewardCount; } SetContent(); }