public PRefreshGeneralOrder() : base("refresh_general", null, (string[] args) => { List <PSkillInfo> SkillInfoList = new List <PSkillInfo>(); int PlayerIndex = Convert.ToInt32(args[1]); string GeneralName = args[2]; int SkillCount = Convert.ToInt32(args[3]); for (int i = 4; i + 1 < args.Length; i += 2) { PSkillInfo SkillInfo = FindInstance <PSkillInfo>(args[i])?.Copy(); if (SkillInfo != null) { SkillInfo.Type = FindInstance <PSkillType>(args[i + 1]); SkillInfoList.Add(SkillInfo); } } if (PlayerIndex == PSystem.PlayerIndex) { PUIManager.AddNewUIAction("更新技能栏", () => { PUIManager.GetUI <PMapUI>().InitializeSkillButton(SkillInfoList); }); } PUIManager.AddNewUIAction("更新武将头像", () => { PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].General = ListSubTypeInstances <PGeneral>().Find((PGeneral General) => General.Name.Equals(GeneralName)); PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].General.SkillInfoList = SkillInfoList; PUIManager.GetUI <PMapUI>().PlayerInformationGroup.GroupUIList[PlayerIndex].UpdateInformation(); }); }) { }
public void InitializeSkillButton(List <PSkillInfo> SkillInfos) { void InitializeSkillButton(PToolTipedButton SkillButton, int Index) { SkillButton.gameObject.SetActive(false); if (SkillInfos.Count > Index) { PSkillInfo SkillInfo = SkillInfos[Index]; string ButtonText = SkillInfo.Name; if (SkillInfo.Type.Equals(PSkillType.Lock)) { ButtonText += "[锁定]"; } else if (SkillInfo.Type.Equals(PSkillType.SoftLock)) { ButtonText += "[软锁定]"; } SkillButton.GetComponentInChildren <Text>().text = ButtonText; ColorBlock Colors = SkillButton.colors; Colors.normalColor = SkillInfo.Type.SkillColor; Colors.highlightedColor = SkillInfo.Type.SkillColor; SkillButton.colors = Colors; SkillButton.ToolTip = SkillInfo.ToolTip; SkillButton.onClick.RemoveAllListeners(); SkillButton.onClick.AddListener(() => { PNetworkManager.NetworkClient.Send(new PClickOnSkillOrder(Index.ToString())); }); SkillButton.gameObject.SetActive(true); } } InitializeSkillButton(Skill1Button, 0); InitializeSkillButton(Skill2Button, 1); }
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); }