private void SetValue() { HeroAttr attr = new HeroAttr(this.heroNPC); this.HP = this.GetDes(attr, AttrType.HpMax); this.MP = this.GetDes(attr, AttrType.MpMax); this.ATK = this.GetDes(attr, AttrType.Attack); this.AP = this.GetDes(attr, AttrType.MagicPower); this.ARMOR = this.GetDes(attr, AttrType.Armor); this.MR = this.GetDes(attr, AttrType.MagicResist); this.AS = this.GetDes(attr, AttrType.AttackSpeed); this.AR = this.GetDes(attr, AttrType.AttackRange); this.CS = this.GetDes(attr, AttrType.PhysicCritProp); this.APT = this.GetDes(attr, AttrType.ArmorCut); this.MPT = this.GetDes(attr, AttrType.MagicResistanceCut); this.HPR = this.GetDes(attr, AttrType.HpRestore); this.MPR = this.GetDes(attr, AttrType.MpRestore); this.MS = this.GetDes(attr, AttrType.MoveSpeed); this.Attributes["HP"] = this.HP; this.Attributes["MP"] = this.MP; this.Attributes["ATK"] = this.ATK; this.Attributes["AP"] = this.AP; this.Attributes["ARMOR"] = this.ARMOR; this.Attributes["MR"] = this.MR; this.Attributes["AS"] = this.AS; this.Attributes["AR"] = this.AR; this.Attributes["CS"] = this.CS; this.Attributes["APT"] = this.APT; this.Attributes["MPT"] = this.MPT; this.Attributes["HPR"] = this.HPR; this.Attributes["MPR"] = this.MPR; this.Attributes["MS"] = this.MS; }
/// <summary> /// 加入三个角色属性 /// </summary> /// <param name="ha0"></param> /// <param name="ha1"></param> /// <param name="ha2"></param> /// 作者:胡皓然 public void SetHeroAttr(HeroAttr ha0, HeroAttr ha1, HeroAttr ha2) { _heroes[0] = ha0; _heroes[1] = ha1; _heroes[2] = ha2; _heroNum = 3; _dieChance = 3; }
private void CollectTalent() { Dictionary <AttrType, float> dictionary = new Dictionary <AttrType, float>(); Dictionary <AttrType, float> dictionary2 = new Dictionary <AttrType, float>(); HeroAttr.CellectTalentAttrs(out dictionary, out dictionary2); foreach (KeyValuePair <AttrType, float> current in dictionary) { base.ChangeAttr(current.Key, OpType.Add, current.Value); } foreach (KeyValuePair <AttrType, float> current2 in dictionary2) { base.ChangeAttr(current2.Key, OpType.Mul, current2.Value); } }
private string GetDes(HeroAttr attr, AttrType type) { string result = string.Empty; float basicAttr = attr.GetBasicAttr(type); float num = attr.GetAttr(type) - basicAttr; if (type == AttrType.HitProp || type == AttrType.DodgeProp || type == AttrType.PhysicCritProp) { result = basicAttr.ToString("P0"); } else { result = basicAttr.ToString("f2"); } return(result); }
///<summary> ///获得英雄的信息,由于暂时没有英雄类和技能类,只能返回null,然后把所有信息打印出来 ///</summary> ///<param name="Name"></param> ///作者:韩璐璐 public static HeroAttr GetHeroInformation(String name) { XmlFilePath = Application.dataPath + "\\Heros.xml"; ///初始化一个xml实例 XmlDocument myXmlDoc = new XmlDocument(); ///加载xml文件(参数为xml文件的路径) myXmlDoc.Load(XmlFilePath); ///获得第一个姓名匹配的节点(SelectSingleNode):此xml文件的根节点 XmlNode rootNode = myXmlDoc.SelectSingleNode("Heros"); ///分别获得该节点的InnerXml和OuterXml信息 string innerXmlInfo = rootNode.InnerXml.ToString(); string outerXmlInfo = rootNode.OuterXml.ToString(); ///获得该节点的子节点(即:该节点的第一层子节点) XmlNodeList firstLevelNodeList = rootNode.ChildNodes; ///挨个比对每个英雄节点 foreach (XmlNode node in firstLevelNodeList) { ///如果符合就获得该英雄的信息 if (node.Attributes["Name"].InnerText == name) { int heroId = int.Parse(node.Attributes["heroId"].InnerText); float jump = float.Parse(node.Attributes["Jump"].InnerText); int move = int.Parse(node.Attributes["Move"].InnerText); float height = float.Parse(node.Attributes["Height"].InnerText); SkillTree skillTree = new SkillTree(); List <InputReceiver.dir> dirList; ///获取该英雄的技能属性 XmlNodeList secondLevelNodeList = node.ChildNodes; foreach (XmlNode secondNode in secondLevelNodeList) { if (secondNode.Name == "Skills") { Skill skill = new Skill(); XmlNodeList skillList = secondNode.ChildNodes; foreach (XmlNode skillNode in skillList) { skill = new Skill(); dirList = new List <InputReceiver.dir>(); XmlNodeList skillKeyList = skillNode.ChildNodes; skill._skillName = skillNode.Attributes["SkillName"].InnerText; foreach (XmlNode skillKeyNode in skillKeyList) { ///获得技能的各个属性 if (skillKeyNode.Name == "IsCreated") { bool isCreated = (int.Parse(skillKeyNode.InnerText) == 0) ? false : true; skill._isCreator = isCreated; } if (skillKeyNode.Name == "offset") { XmlNodeList offsetAttrList = skillKeyNode.ChildNodes; float x = 0, y = 0; foreach (XmlNode offsetAttr in offsetAttrList) { if (offsetAttr.Name == "x") { x = float.Parse(offsetAttr.InnerText); } if (offsetAttr.Name == "y") { y = float.Parse(offsetAttr.InnerText); } Vector3 vector = new Vector3(x, y, 0); skill._offset = vector; } } if (skillKeyNode.Name == "AddRage") { int addRage = int.Parse(skillKeyNode.InnerText); skill._addRage = addRage; } if (skillKeyNode.Name == "HitAddRage") { int hitaddRage = int.Parse(skillKeyNode.InnerText); skill._hitAddRage = hitaddRage; } if (skillKeyNode.Name == "aggressivity") { int aggressivity = int.Parse(skillKeyNode.InnerText); skill._aggressivity = aggressivity; } if (skillKeyNode.Name == "skillId") { int skillId = int.Parse(skillKeyNode.InnerText); skill._skillId = skillId; } if (skillKeyNode.Name == "time") { float time = float.Parse(skillKeyNode.InnerText); skill._time = time; } if (skillKeyNode.Name == "BeforeAT") { float beforeAT = float.Parse(skillKeyNode.InnerText); skill._beforeAT = beforeAT; } if (skillKeyNode.Name == "firstAfterAT") { float firstAfterAT = float.Parse(skillKeyNode.InnerText); skill._afterATFirst = firstAfterAT; } if (skillKeyNode.Name == "lastAfterAT") { float lastAfterAT = float.Parse(skillKeyNode.InnerText); skill._afterATLast = lastAfterAT; } if (skillKeyNode.Name == "existTime") { float existTime = float.Parse(skillKeyNode.InnerText); skill._existTime = existTime; } if (skillKeyNode.Name == "isChild") { bool isChild = (int.Parse(skillKeyNode.InnerText) == 0) ? false : true; skill._isChild = isChild; } if (skillKeyNode.Name == "tralls") { XmlNodeList trallsList = skillKeyNode.ChildNodes; foreach (XmlNode trallNode in trallsList) { dirList.Add((InputReceiver.dir)(int.Parse(trallNode.InnerText))); } } } skill.SetFunc(); ///把技能添加到技能树 skillTree.Add(skill); } } } ///构造英雄 HeroAttr hero = new HeroAttr(name, heroId, jump, move, height, skillTree); return(hero); } } return(null); }
private void CollectEquipAttr(string equips, int magicStar, ref Dictionary <AttrType, float> addDict, ref Dictionary <AttrType, float> mulDict) { if (addDict == null || addDict.Keys.Count == 0) { addDict = new Dictionary <AttrType, float>(); } if (mulDict == null || mulDict.Keys.Count == 0) { mulDict = new Dictionary <AttrType, float>(); } string[] stringValue = StringUtils.GetStringValue(equips, ','); for (int i = 0; i < stringValue.Length; i++) { SysGameItemsVo dataById = BaseDataMgr.instance.GetDataById <SysGameItemsVo>(stringValue[i]); if (dataById == null) { Debug.LogError("HeroAttr.CollectEquipAttr , equips [" + equips + "] has null id: " + stringValue[i]); } else { string[] stringValue2 = StringUtils.GetStringValue(dataById.attribute, ','); for (int j = 0; j < stringValue2.Length; j++) { string[] array = stringValue2[j].Split(new char[] { '|' }); AttrType type = (AttrType)int.Parse(array[0]); if (!array[1].Contains("%")) { HeroAttr.AddToDict(ref addDict, type, float.Parse(array[1])); } else { string text = array[1].Trim(); float value = float.Parse(text.Substring(0, text.Length - 1)) / 100f; HeroAttr.AddToDict(ref mulDict, type, value); } } if (magicStar > 0) { string[] stringValue3 = StringUtils.GetStringValue(dataById.enchant_attribute, ','); for (int k = 0; k < stringValue3.Length; k++) { string[] array2 = stringValue3[k].Split(new char[] { '|' }); AttrType type2 = (AttrType)int.Parse(array2[0]); if (!array2[1].Contains("%")) { HeroAttr.AddToDict(ref addDict, type2, float.Parse(array2[1]) * (float)magicStar); } else { string text2 = array2[1].Trim(); float num = float.Parse(text2.Substring(0, text2.Length - 1)) / 100f; HeroAttr.AddToDict(ref mulDict, type2, num * (float)magicStar); } } } } } }
/// <summary> /// 加入一个角色属性 /// </summary> /// <param name="ha"></param> /// 作者:胡皓然 public void SetHeroAttr(HeroAttr ha) { _heroes[0] = ha; _heroNum = 1; _dieChance = 2; }