public void Show(string _ToolTip, Vector3 Position) { Open(); UIBackgroundImage.GetComponent <RectTransform>().position = Position; ToolTipText.text = _ToolTip; UIBackgroundImage.GetComponent <RectTransform>().sizeDelta = new Vector2(200.0f, GeneratorForLayout.GetPreferredHeight(_ToolTip, ToolTipText.GetGenerationSettings(new Vector2(ToolTipText.GetPixelAdjustedRect().size.x, 0.0f))) / ToolTipText.pixelsPerUnit); }
public PSeat(Transform _Background, int _Index) : base(_Background) { Index = _Index; InitializeControls <Button>(); Background = UIBackgroundImage.GetComponent <Image>(); Close(); }
public void Initialize(string Text, int _Index, int ButtonNumber, Vector3 CenterPoint, float Delta, string ToolTip) { Index = _Index; UIBackgroundImage.GetComponent <RectTransform>().position = CenterPoint + new Vector3(0, Delta * ButtonNumber / 2 - Delta * (Index + 1)); MessageText = Text; UIBackgroundImage.GetComponentInChildren <Text>().text = Text; UIBackgroundImage.GetComponent <PToolTipedButton>().onClick.AddListener(() => { IsChosen = true; }); UIBackgroundImage.GetComponent <PToolTipedButton>().ToolTip = ToolTip; }
public PCardUI Initialize(string CardName, Vector3 PrototypePosition, int _Index, int Count) { float Interval = 105.0f; float AllLength = UIBackgroundImage.parent.gameObject.GetComponent <RectTransform>().rect.width; if (Interval * Count > AllLength && Count > 1) { Interval = (AllLength - 105.0f) / (Count - 1); } Sprite Image = Resources.Load <Sprite>("Images/Cards/" + CardName); if (Image != null) { UIBackgroundImage.GetComponent <Image>().sprite = Image; UIBackgroundImage.localScale = new Vector3(1, 1, 1); UIBackgroundImage.localPosition = new Vector3(Interval * (_Index % 1000) + PrototypePosition.x, 0.0f, 0.0f); Index = _Index; CardButton.onClick.AddListener(() => { PNetworkManager.NetworkClient.Send(new PClickOnCardOrder(Index.ToString())); }); CardButton.ToolTip = FindInstance <PCardToolTip>(CardName).ToolTip; } return(this); }
public PCardUI(Transform _Background) : base(_Background) { CardButton = UIBackgroundImage.GetComponent <PToolTipedButton>(); Close(); }
public PGeneralButtonUI(Transform _Background) : base(_Background) { GeneralButton = UIBackgroundImage.GetComponent <Button>(); Close(); }
public PGeneralButtonUI Initialize(Transform Prototype, int _Index, int LineCapacity, PGeneral _General) { Index = _Index; General = _General; UIBackgroundImage.GetComponentInChildren <Text>().text = General.Name; UIBackgroundImage.localScale = new Vector3(1, 1, 1); UIBackgroundImage.localPosition = new Vector3(70.0f * (Index % LineCapacity) + Prototype.localPosition.x, -70.0f * (Index / LineCapacity) + Prototype.localPosition.y, 0.0f); void InvokeBuyGeneral(Button TargetButton) { string Method = (TargetButton.Equals(PUIManager.GetUI <PGeneralUI>().BuyArchPointButton) ? "成就点" : "银两"); TargetButton.onClick.RemoveAllListeners(); TargetButton.GetComponentInChildren <Text>().text = General.Cost.ToString() + Method + " 购买"; TargetButton.onClick.AddListener(() => { if (!PSystem.UserManager.GeneralList.Contains(General.Name)) { bool CanPurchase = false; if (Method.Equals("成就点") && PSystem.UserManager.ArchPoint >= General.Cost) { PSystem.UserManager.ArchPoint -= General.Cost; CanPurchase = true; } else if (Method.Equals("银两") && PSystem.UserManager.Money >= General.Cost) { PSystem.UserManager.Money -= General.Cost; CanPurchase = true; } if (CanPurchase) { PSystem.UserManager.GeneralList.Add(General.Name); PSystem.UserManager.Write(); UIBackgroundImage.GetComponent <Image>().color = PGeneralUI.Config.GotGeneralColor; PUIManager.GetUI <PGeneralUI>().BuyArchPointButton.interactable = false; PUIManager.GetUI <PGeneralUI>().BuyMoneyButton.interactable = false; } } }); if (PSystem.UserManager.GeneralList.Contains(General.Name)) { TargetButton.interactable = false; } else { TargetButton.interactable = true; } } GeneralButton.onClick.AddListener(() => { PUIManager.GetUI <PGeneralUI>().GeneralInfoInputField.text = General.Name + "\n" + "性别:" + General.Sex + "\n" + "时代:" + General.Age + "\n" + string.Join("\n", General.SkillList.ConvertAll((PSkill Skill) => { PSkillInfo SkillInfo = ListInstance <PSkillInfo>().Find((PSkillInfo Info) => Info.Name.Equals(Skill.Name)); if (SkillInfo == null) { return(Skill.Name); } else { return(Skill.Name + ":" + SkillInfo.ToolTip); } })) + "\n\n" + General.Tips; InvokeBuyGeneral(PUIManager.GetUI <PGeneralUI>().BuyArchPointButton); InvokeBuyGeneral(PUIManager.GetUI <PGeneralUI>().BuyMoneyButton); }); UIBackgroundImage.gameObject.SetActive(true); return(this); }