using System.Collections.Generic; using GCGame.Table; using UnityEngine; using UnityEngine.UI; public class AttrInfo { public int m_attrType; //该属性的类型 public float m_attrValue; //该属性的值 public bool m_isChange; //该属性值是否有修改 public string m_name; //属性名字 public string m_sendKeyStr; //发送给服务器的格式化字符串 public int m_Type; // 属性属于哪一类型 0一级属性 1基础属性 2特殊属性 3效果属性 4元素属性 5资源属性 6技能等级属性 public AttrInfo(int type, string name, bool isChange, int attrType, float attrValue, string sendKey) { m_Type = type; m_attrType = attrType; m_name = name; m_isChange = isChange; m_attrValue = attrValue; m_sendKeyStr = sendKey; } public void SendGmInfo() { // if (m_name == "灵玉" && PlatformHelper.UseSdk()) // { // PlatformHelper.Pay(m_attrValue, "测试"); // } // else // { var packet = (CG_GMCOMMAND) PacketDistributed.CreatePacket(MessageID.PACKET_CG_GMCOMMAND); m_sendKeyStr = m_sendKeyStr.Replace(' ', ','); packet.Cmd = string.Format(m_sendKeyStr, m_attrValue); packet.SendPacket(); // } } } public class GMPanel : MonoBehaviour { private readonly Dictionary AttrParentObjs = new Dictionary(); private readonly List m_clones = new List(); private readonly Dictionary m_Clones = new Dictionary(); //此处可以使用表格代替,看有没有必要使用表格 //所有面板上需要展示的信息 private readonly Dictionary m_info = new Dictionary { //一级属性 { 0, new AttrInfo(0, "体质", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.CONSTITU) + "{0}") }, {1, new AttrInfo(0, "精力", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MORFIB) + "{0}")}, { 2, new AttrInfo(0, "力量", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.STRENGTH) + "{0}") }, { 3, new AttrInfo(0, "智力", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.INTELLENG) + "{0}") }, {4, new AttrInfo(0, "敏捷", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.AGILE) + "{0}")}, { 5, new AttrInfo(0, "法术防御", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MAGDEF) + "{0}") }, //基础属性 {6, new AttrInfo(1, "等级", false, 0, 0, "inclevel,{0}")}, {7, new AttrInfo(1, "副本", false, 0, 0, "createfb {0} 1")}, {8, new AttrInfo(1, "最大生命", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MAXHP) + "{0}")}, {9, new AttrInfo(1, "最大法力", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MAXMP) + "{0}")}, { 10, new AttrInfo(1, "法术攻击", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MAGATTACK) + "{0}") }, { 90, new AttrInfo(1, "物理攻击", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.PYSATTACK) + "{0}") }, { 11, new AttrInfo(1, "治疗量", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.CUREAMOUNT) + "{0}") }, { 12, new AttrInfo(1, "物理防御", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.PYSDEF) + "{0}") }, { 13, new AttrInfo(1, "法术防御", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MAGDEF) + "{0}") }, { 14, new AttrInfo(1, "晕命中", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.MAGDEF) + "{0}") }, {15, new AttrInfo(1, "闪避", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DODGE) + "{0}")}, { 16, new AttrInfo(1, "暴击", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.CRITICAL) + "{0}") }, { 17, new AttrInfo(1, "暴抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DECRITICAL) + "{0}") }, { 18, new AttrInfo(1, "修为", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.ABILITYLEVEL) + "{0}") }, //特殊属性 {19, new AttrInfo(2, "穿透", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.STRIKE) + "{0}")}, { 20, new AttrInfo(2, "坚韧", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DUCTICAL) + "{0}") }, { 21, new AttrInfo(2, "暴击伤害减免", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.CRITIMIS) + "{0}") }, { 22, new AttrInfo(2, "无视防御伤害", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.INGDEF) + "{0}") }, { 23, new AttrInfo(2, "固定伤害减免", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.REDUCEDAM) + "{0}") }, {24, new AttrInfo(2, "对天玑伤害加成", false, 0, 0, "1")}, {25, new AttrInfo(2, "对六扇伤害加成", false, 0, 0, "1")}, {26, new AttrInfo(2, "对玄女伤害加成", false, 0, 0, "1")}, {27, new AttrInfo(2, "对蜀山伤害加成", false, 0, 0, "1")}, { 28, new AttrInfo(2, "对宠物加成", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DAMGRATEADDPET) + "{0}") }, { 29, new AttrInfo(2, "对BOSS加成", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DAMGRATEADDBOSS) + "{0}") }, { 30, new AttrInfo(2, "对小怪加成", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DAMGRATEADDMONSTER) + "{0}") }, //效果属性 { 31, new AttrInfo(3, "眩晕增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DIZZYENHANCE) + "{0}") }, { 32, new AttrInfo(3, "眩晕抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DIZZYEDEF) + "{0}") }, { 33, new AttrInfo(3, "沉默增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SILENTENHANCE) + "{0}") }, { 34, new AttrInfo(3, "沉默抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SILENTDEF) + "{0}") }, { 35, new AttrInfo(3, "定身增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.IMMOBENHANCE) + "{0}") }, { 36, new AttrInfo(3, "定身抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.IMMOBDEF) + "{0}") }, { 37, new AttrInfo(3, "击退增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.REPELENHANCE) + "{0}") }, { 38, new AttrInfo(3, "击退抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.REPELDEF) + "{0}") }, { 39, new AttrInfo(3, "变羊增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.POLYMORPHENHANCE) + "{0}") }, { 40, new AttrInfo(3, "变羊抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.POLYMORPHDEF) + "{0}") }, { 41, new AttrInfo(3, "昏迷增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.HMENHANCE) + "{0}") }, { 42, new AttrInfo(3, "昏迷抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.HMDEF) + "{0}") }, { 43, new AttrInfo(3, "失明增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SMENHANCE) + "{0}") }, { 44, new AttrInfo(3, "失明抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SMDEF) + "{0}") }, { 45, new AttrInfo(3, "石化增强", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SHENHANCE) + "{0}") }, { 46, new AttrInfo(3, "石化抗性", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SHDEF) + "{0}") }, //元素属性 { 47, new AttrInfo(4, "火抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.HUOGDEF) + "{0}") }, { 48, new AttrInfo(4, "忽视火抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.HUOGIGNDEF) + "{0}") }, {49, new AttrInfo(4, "风抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.FGDEF) + "{0}")}, { 50, new AttrInfo(4, "忽视风抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.FGIGNDEF) + "{0}") }, {51, new AttrInfo(4, "毒抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DUGDEF) + "{0}")}, { 52, new AttrInfo(4, "忽视毒抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DUGIGNDEF) + "{0}") }, { 53, new AttrInfo(4, "幻抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.HUANGDEF) + "{0}") }, { 54, new AttrInfo(4, "忽视幻抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.HUANGIFNDEF) + "{0}") }, {55, new AttrInfo(4, "光抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.GGDEF) + "{0}")}, { 56, new AttrInfo(4, "忽视光抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.GGIGNDEF) + "{0}") }, {57, new AttrInfo(4, "冰抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DGDEF) + "{0}")}, { 58, new AttrInfo(4, "忽视冰抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.BGIGNDEF) + "{0}") }, {59, new AttrInfo(4, "电抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DGDEF) + "{0}")}, { 60, new AttrInfo(4, "忽视电抗", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.DGIGNDEF) + "{0}") }, //资源属性 { 61, new AttrInfo(5, "元宝", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.BIND_YUANBAO) + "{0}") }, { 62, new AttrInfo(5, "灵玉", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.YUANBAO) + "{0}") }, { 63, new AttrInfo(5, "银两", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.YINLIANG) + "{0}") }, { 64, new AttrInfo(5, "银票", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.BIND_YINLIANG) + "{0}") }, //{65,new AttrInfo(5,"经验",false,0,0,"incexp,{0}")}, //{66,new AttrInfo(5,"专属经验",false,0,0,"incrprivateexp {0}")}, { 65, new AttrInfo(5, "经验", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.PROPUSER_EXP) + "{0}") }, { 66, new AttrInfo(5, "专属经验", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.PRIVATEEXP) + "{0}") }, {67, new AttrInfo(5, "帮贡", false, 0, 0, "inccontribute")}, { 68, new AttrInfo(5, "关宁积分", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.GUANNING) + "{0}") }, { 69, new AttrInfo(5, "情谊积分", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.QINGYIZHI) + "{0}") }, { 100, new AttrInfo(5, "比武积分", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.FIGHTSCORE) + "{0}") }, { 101, new AttrInfo(5, "门派积分", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.CHAELLENGESCORE) + "{0}") }, { 102, new AttrInfo(5, "夺宝积分", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SNATCHSCORE) + "{0}") }, { 103, new AttrInfo(5, "受赠积分", false, 0, 0, string.Format("setprop {0} ", (int) PropID.PropertyID.SHOUZENG) + "{0}") }, //技能等级 {71, new AttrInfo(6, "技能1等级", false, 0, 0, "1")}, {72, new AttrInfo(6, "技能2等级", false, 0, 0, "1")}, {73, new AttrInfo(6, "技能3等级", false, 0, 0, "1")}, {74, new AttrInfo(6, "技能4等级", false, 0, 0, "1")}, {75, new AttrInfo(6, "技能5等级", false, 0, 0, "1")}, {76, new AttrInfo(6, "技能6等级", false, 0, 0, "1")}, {77, new AttrInfo(6, "技能7等级", false, 0, 0, "1")}, {78, new AttrInfo(6, "技能8等级", false, 0, 0, "1")}, {79, new AttrInfo(6, "技能9等级", false, 0, 0, "1")}, {80, new AttrInfo(6, "技能10等级", false, 0, 0, "1")}, //功能玩法 {81, new AttrInfo(7, "吉星高照", false, 0, 0, "1")}, {82, new AttrInfo(7, "守财奴", false, 0, 0, "1")}, {83, new AttrInfo(7, "采薇", false, 0, 0, "1")}, {84, new AttrInfo(7, "帮会大贼", false, 0, 0, "1")}, {85, new AttrInfo(7, "科举答题", false, 0, 0, "1")}, {86, new AttrInfo(7, "帮会跑商", false, 0, 0, "1")}, {87, new AttrInfo(7, "货运任务", false, 0, 0, "1")}, {88, new AttrInfo(7, "关宁战场", false, 0, 0, "1")}, {89, new AttrInfo(7, "帮派战场", false, 0, 0, "1")} }; public UIContainerBase _BaseItemsContainer; //基础属性框 public UIContainerBase _DataItemsContainer; //元素属性框 public UIContainerBase _EffectItemsContainer; //效果属性框 public UIContainerBase _FirstItemsContainer; //一级属性框 public UIContainerBase _FunItemsContainer; //功能玩法属性框 public UIContainerBase _ResourceItemsContainer; //资源属性框 public UIContainerBase _SkillItemsContainer; //技能属性框 public UIContainerBase _SpecialItemsContainer; //特殊属性框 public GameObject AddItemWnd; //添加物品 public GameObject AttrInfoWnd; //属性面板 public GameObject FunInfoWnd; //功能面板 public InputField m_ClassID; public InputField m_inputNum; public InputField m_SearchName; public InputField m_SubClassID; //宠物 public GameObject PetItemObj; private void Start() { AttrParentObjs.Add(0, _FirstItemsContainer); AttrParentObjs.Add(1, _BaseItemsContainer); AttrParentObjs.Add(2, _SpecialItemsContainer); AttrParentObjs.Add(3, _EffectItemsContainer); AttrParentObjs.Add(4, _DataItemsContainer); AttrParentObjs.Add(5, _ResourceItemsContainer); AttrParentObjs.Add(6, _SkillItemsContainer); AttrParentObjs.Add(7, _FunItemsContainer); ShowAttrWnd(); //开启UI时,激活聊天框GM按钮 FunctionButtonLogic.Instance()._BtnGM.SetActive(true); } public void ShowItemsWnd() { if (AttrInfoWnd != null) AttrInfoWnd.SetActive(false); if (FunInfoWnd != null) FunInfoWnd.SetActive(false); if (AddItemWnd != null) AddItemWnd.SetActive(true); ShowItems(); } public void ShowAttrWnd() { if (AttrInfoWnd != null) AttrInfoWnd.SetActive(true); if (FunInfoWnd != null) FunInfoWnd.SetActive(false); if (AddItemWnd != null) AddItemWnd.SetActive(false); InitAttarContent(0); InitAttarContent(1); InitAttarContent(2); InitAttarContent(3); InitAttarContent(4); } public void ShowFunWnd() { if (AttrInfoWnd != null) AttrInfoWnd.SetActive(false); if (FunInfoWnd != null) FunInfoWnd.SetActive(true); if (AddItemWnd != null) AddItemWnd.SetActive(false); InitAttarContent(5); InitAttarContent(6); InitAttarContent(7); } public void InitAttarContent(int type) { var Valus = new List(m_info.Values); var showItems = new List(); for (var i = 0; i < Valus.Count; i++) { var info = Valus[i]; if (info.m_Type == type) showItems.Add(info); } AttrParentObjs[type].InitContentItem(showItems); } public void OnAttrInputChange(int index, InputField input) { if (input == null) return; if (m_info.ContainsKey(index) == false) return; float value = 0; float.TryParse(input.text, out value); m_info[index].m_attrValue = value; } public void OnCloseClick() { UIManager.CloseUI(UIInfo.GMWnd); } public void OnOkBtnClick() { var valus = new List(m_info.Values); for (var i = 0; i < valus.Count; i++) { var info = valus[i]; if (info.m_isChange) { info.m_isChange = false; info.SendGmInfo(); } } UIManager.CloseUI(UIInfo.GMWnd); } public void SearchItem() { if (m_SearchName == null) return; if (m_Clones == null) return; if (m_Clones.ContainsKey(m_SearchName.text)) m_Clones[m_SearchName.text].transform.SetAsFirstSibling(); else ShowSearchItems(); } public void ShowSearchItems() { var items = TableManager.GetCommonItem().Values; for (var i = 0; i < m_clones.Count; i++) { m_clones[i].transform.SetParent(null); m_clones[i].SetActive(false); Destroy(m_clones[i]); } m_clones.Clear(); m_Clones.Clear(); foreach (var item in items) if (item.Id.ToString() == m_SearchName.text || item.Name.Contains(m_SearchName.text)) { var newObj = Instantiate(PetItemObj); if (newObj == null) continue; newObj.SetActive(true); newObj.transform.SetParent(PetItemObj.transform.parent); newObj.transform.localPosition = Vector3.zero; newObj.transform.localScale = PetItemObj.transform.localScale; m_Clones[item.Name] = newObj; m_clones.Add(newObj); var image = newObj.GetComponentInChildren(); if (image != null) { LoadAssetBundle.Instance.SetImageSprite(image, item.Icon); if (item.QualityEffect > 0) CommonItemContainerItem.ShowQualityEffect(true, item.QualityEffect, image.transform); else CommonItemContainerItem.ShowQualityEffect(false, item.QualityEffect, image.transform); } var texts = newObj.GetComponentsInChildren(); for (var i = 0; i < texts.Length; i++) { if (texts[i].name == "Name") texts[i].text = item.Name; if (texts[i].name == "Id1") texts[i].text = item.ClassID.ToString(); if (texts[i].name == "Id2") texts[i].text = item.SubClassID.ToString(); } var itemId = item.Id; var btn = newObj.GetComponentInChildren