Example #1
0
 public SkillLeaf(string id, TargetPicker targetPicker,
                  string animationName, float skillTime) : base(id)
 {
     this.m_targetPicker = targetPicker;
     this.mAnimationName = animationName;
     this.mSkillTime     = skillTime;
 }
Example #2
0
        /// <summary>
        /// 返回此节点指向的子技能对应的SkillBase
        /// </summary>
        /// <param name="skillBaseNode"></param>
        /// <returns></returns>
        private static SkillBase GetSkillBase(string skillBaseId)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(MYXZAssetBundleManager.Instance.LoadOrGetAssetBundle(
                                MYXZXmlReader.GetConfigAssetBundlePath("Skill")
                                ).LoadAsset <TextAsset>(skillBaseId).text); //读取此XML字符串至doc
            }
            catch (XmlException e)
            {
                Debug.LogException(e);
                return(null);
            }

            TargetPicker attackArea    = null;
            string       animationName = "";
            float        skillTime     = 0.0f;

            foreach (XmlNode childNode in doc.FirstChild.ChildNodes)
            {
                if (childNode.Name.Equals("AttackArea"))
                {
                    switch (childNode.Attributes["Mode"].Value)
                    {
                    case "Point":
                        attackArea = new PointTargetPicker(
                            float.Parse(childNode.Attributes["MinDistance"].Value),
                            float.Parse(childNode.Attributes["MaxDistance"].Value),
                            float.Parse(childNode.Attributes["Angle"].Value));
                        break;

                    case "Rect":
                        attackArea = new RectTargetPicker(
                            float.Parse(childNode.Attributes["Width"].Value),
                            float.Parse(childNode.Attributes["Length"].Value));
                        break;
                    }
                }

                if (childNode.Name.Equals("Animation"))
                {
                    animationName = childNode.Attributes["Name"].Value;
                }

                if (childNode.Name.Equals("SkillTime"))
                {
                    skillTime = float.Parse(childNode.InnerText);
                }
            }
            return(new SkillBase(skillBaseId, attackArea, animationName, skillTime));
        }