Exemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string jsonStr = value.ToString();

            ObservableCollection <SkillCondition> skillConditionList = new ObservableCollection <SkillCondition>();

            // NOTE thy 方案一 使用JsonConverter转换内部派生实例
            // skillConditionList = JsonConvert.DeserializeObject<ObservableCollection<SkillCondition>>(jsonStr);

            // NOTE thy 方案二 自己遍历每个元素,单独调用反序列化
            JArray jArray = JArray.Parse(jsonStr);

            foreach (JObject jo in jArray)
            {
                String className = jo["ClassName"].ToString();
                jo.Remove("ClassName");

                if (!AssemblyManager.Instance.SkillConditionTypes.ContainsKey(className))
                {
                    LogManager.Instance.Warn("找不到对应的动态类: " + className + ", 此数据已直接丢弃。");
                    LogManager.Instance.Warn("请确保动态类型配置中已定义了此类型,然后重启编辑器。");
                    continue;
                }

                Type           type           = AssemblyManager.Instance.SkillConditionTypes[className];
                SkillCondition skillCondition = JsonConvert.DeserializeObject(jo.ToString(), type) as SkillCondition;

                skillConditionList.Add(skillCondition);
            }

            return(skillConditionList);
        }
Exemplo n.º 2
0
    private static void HandleRegionSkills(GameSession session, PacketReader packet)
    {
        long   skillSn     = packet.ReadLong();
        byte   mode        = packet.ReadByte();
        int    unknown     = packet.ReadInt();
        int    attackIndex = packet.ReadInt();
        CoordF position    = packet.Read <CoordF>();
        CoordF rotation    = packet.Read <CoordF>();
        // What are these values used? Check client vs server?

        // TODO: Verify rest of skills to proc correctly.
        // TODO: Send status correctly when Region attacks are proc.

        SkillCast parentSkill = session.Player.FieldPlayer.SkillCast;

        if (parentSkill is null || parentSkill.SkillSn != skillSn)
        {
            return;
        }

        SkillAttack skillAttack = parentSkill.GetSkillMotions().FirstOrDefault()?.SkillAttacks.FirstOrDefault();

        if (skillAttack is null)
        {
            return;
        }

        if (skillAttack.CubeMagicPathId == 0 && skillAttack.MagicPathId == 0)
        {
            return;
        }

        SkillCondition skillCondition = skillAttack.SkillConditions.FirstOrDefault(x => x.IsSplash);

        if (skillCondition is null)
        {
            return;
        }

        SkillCast skillCast = new(skillCondition.SkillId, skillCondition.SkillLevel, GuidGenerator.Long(), session.ServerTick, parentSkill)
        {
            CasterObjectId = session.Player.FieldPlayer.ObjectId,
            SkillAttack    = skillAttack,
            Duration       = skillCondition.FireCount * 1000,
            Interval       = skillCondition.Interval
        };

        RegionSkillHandler.HandleEffect(session, skillCast, attackIndex);
    }

    #endregion
}
Exemplo n.º 3
0
        private void onBtn_AddAwards(object sender, RoutedEventArgs e)
        {
            if (lsbAwards.ItemsSource == null)
            {
                return;
            }

            SkillConditionPickWindow window = new SkillConditionPickWindow();

            if (window.ShowDialog() == true)
            {
                SkillCondition newCondition = (SkillCondition)Activator.CreateInstance(window.PickedType);
                var            list         = (ObservableCollection <SkillCondition>)lsbAwards.ItemsSource;
                list.Add(newCondition);
            }
        }
Exemplo n.º 4
0
        private void lsbConditions_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            spConditionParams.Children.Clear();

            if (lsbConditions.SelectedItem == null)
            {
                return;
            }

            SkillCondition skillCondition = lsbConditions.SelectedItem as SkillCondition;

            Type skillConditionType = skillCondition.GetType();

            foreach (var p in skillConditionType.GetProperties())
            {
                Grid grid = createPropEntryGrid(p);
                spConditionParams.Children.Add(grid);
            }
        }
Exemplo n.º 5
0
        protected override List <SkillMetadata> Parse()
        {
            List <SkillMetadata> skillList = new List <SkillMetadata>();

            foreach (PackFileEntry entry in Resources.XmlReader.Files)
            {
                // Parsing Skills
                if (entry.Name.StartsWith("skill"))
                {
                    XmlDocument document  = Resources.XmlReader.GetXmlDocument(entry);
                    XmlNode     ui        = document.SelectSingleNode("/ms2/basic/ui");
                    XmlNode     kinds     = document.SelectSingleNode("/ms2/basic/kinds");
                    XmlNode     stateAttr = document.SelectSingleNode("/ms2/basic/stateAttr");
                    XmlNodeList levels    = document.SelectNodes("/ms2/level");

                    int    skillId         = int.Parse(Path.GetFileNameWithoutExtension(entry.Name));
                    string skillState      = kinds.Attributes["state"]?.Value ?? "";
                    byte   skillAttackType = byte.Parse(ui.Attributes["attackType"]?.Value ?? "0");
                    byte   skillType       = byte.Parse(kinds.Attributes["type"].Value);
                    byte   skillSubType    = byte.Parse(kinds.Attributes["subType"]?.Value ?? "0");
                    byte   skillElement    = byte.Parse(kinds.Attributes["element"].Value);
                    byte   skillSuperArmor = byte.Parse(stateAttr.Attributes["superArmor"].Value);
                    bool   skillRecovery   = int.Parse(kinds.Attributes["spRecoverySkill"]?.Value ?? "0") == 1;

                    List <SkillLevel> skillLevels = new List <SkillLevel>();
                    foreach (XmlNode level in levels)
                    {
                        // Getting all skills level
                        string feature    = level.Attributes["feature"]?.Value ?? "";
                        int    levelValue = int.Parse(level.Attributes["value"].Value ?? "0");
                        // We prevent duplicates levels from older balances.
                        if (skillLevels.Exists(level => level.Level == levelValue))
                        {
                            continue;
                        }
                        int    spirit       = int.Parse(level.SelectSingleNode("consume/stat").Attributes["sp"]?.Value ?? "0");
                        int    stamina      = int.Parse(level.SelectSingleNode("consume/stat").Attributes["ep"]?.Value ?? "0");
                        float  damageRate   = float.Parse(level.SelectSingleNode("motion/attack/damageProperty")?.Attributes["rate"].Value ?? "0");
                        string sequenceName = level.SelectSingleNode("motion/motionProperty")?.Attributes["sequenceName"].Value ?? "";
                        string motionEffect = level.SelectSingleNode("motion/motionProperty")?.Attributes["motionEffect"].Value ?? "";

                        SkillUpgrade skillUpgrade = new SkillUpgrade();
                        if (level.SelectSingleNode("motion/upgrade")?.Attributes != null)
                        {
                            int     upgradeLevel       = int.Parse(level.SelectSingleNode("motion/upgrade").Attributes["level"].Value ?? "0");
                            int[]   upgradeSkills      = level.SelectSingleNode("motion/upgrade").Attributes["skillIDs"].Value.Split(",").Select(int.Parse).ToArray();
                            short[] upgradeSkillsLevel = level.SelectSingleNode("motion/upgrade").Attributes["skillLevels"].Value.Split(",").Select(short.Parse).ToArray();

                            skillUpgrade = new SkillUpgrade(upgradeLevel, upgradeSkills, upgradeSkillsLevel);
                        }

                        // Getting all Attack attr in each level.
                        List <SkillAttack>    skillAttacks    = new List <SkillAttack>();
                        List <SkillCondition> skillConditions = new List <SkillCondition>();

                        XmlNodeList conditionSkills = level.SelectNodes("motion/attack/conditionSkill") ?? level.SelectNodes("conditionSkill");
                        foreach (XmlNode conditionSkill in conditionSkills)
                        {
                            int            conditionSkillId    = int.Parse(conditionSkill.Attributes["skillID"]?.Value ?? "0");
                            short          conditionSkillLevel = short.Parse(conditionSkill.Attributes["level"]?.Value ?? "0");
                            bool           splash         = conditionSkill.Attributes["splash"]?.Value == "1";
                            byte           target         = byte.Parse(conditionSkill.Attributes["skillTarget"].Value ?? "0");
                            byte           owner          = byte.Parse(conditionSkill.Attributes["skillOwner"]?.Value ?? "0");
                            SkillCondition skillCondition = new SkillCondition(conditionSkillId, conditionSkillLevel, splash, target, owner);

                            skillConditions.Add(skillCondition);
                        }

                        XmlNodeList attackListAttr = level.SelectNodes("motion/attack");
                        foreach (XmlNode attackAttr in attackListAttr)
                        {
                            // Many skills has a condition to proc another skill.
                            // We capture that as a list, since each Attack attr has one at least.
                            byte        attackPoint     = byte.Parse(Regex.Match(attackAttr.Attributes["point"]?.Value, @"\d").Value);
                            short       targetCount     = short.Parse(attackAttr.Attributes["targetCount"].Value);
                            long        magicPathId     = long.Parse(attackAttr.Attributes["magicPathID"]?.Value ?? "0");
                            long        cubeMagicPathId = long.Parse(attackAttr.Attributes["cubeMagicPathID"]?.Value ?? "0");
                            SkillAttack skillAttack     = new SkillAttack(attackPoint, targetCount, magicPathId, cubeMagicPathId);

                            skillAttacks.Add(skillAttack);
                        }

                        SkillMotion skillMotion = new SkillMotion(sequenceName, motionEffect);
                        SkillLevel  skillLevel  = new SkillLevel(levelValue, spirit, stamina, damageRate, feature, skillMotion, skillAttacks, skillConditions, skillUpgrade);
                        skillLevels.Add(skillLevel);
                    }
                    skillList.Add(new SkillMetadata(skillId, skillLevels, skillState, skillAttackType, skillType, skillSubType, skillElement, skillSuperArmor, skillRecovery));
                    continue;
                }

                // Parsing SubSkills
                if (entry.Name.StartsWith("table/job"))
                {
                    XmlDocument document = Resources.XmlReader.GetXmlDocument(entry);
                    XmlNodeList jobs     = document.SelectNodes("/ms2/job");
                    foreach (XmlNode job in jobs)
                    {
                        // Grabs all the skills and them the jobCode.
                        XmlNodeList skills  = job.SelectNodes("skills/skill");
                        int         jobCode = int.Parse(job.Attributes["code"].Value);
                        foreach (XmlNode skill in skills)
                        {
                            int   id       = int.Parse(skill.Attributes["main"].Value);
                            short maxLevel = short.Parse(skill.Attributes["maxLevel"]?.Value ?? "1");
                            skillList.Find(x => x.SkillId == id).Job      = jobCode;
                            skillList.Find(x => x.SkillId == id).MaxLevel = maxLevel;

                            // If it has subSkill, add as well.
                            if (skill.Attributes["sub"] == null)
                            {
                                continue;
                            }

                            int[] sub = skill.Attributes["sub"].Value.Split(",").Select(int.Parse).ToArray();
                            skillList.Find(x => x.SkillId == id).SubSkills = sub;
                            for (int n = 0; n < sub.Length; n++)
                            {
                                if (skillList.Select(x => x.SkillId).Contains(sub[n]))
                                {
                                    skillList.Find(x => x.SkillId == sub[n]).Job = jobCode;
                                }
                            }
                        }
                        XmlNodeList learnSkills = job.SelectNodes("learn/skill");
                        foreach (XmlNode learnSkill in learnSkills)
                        {
                            int id = int.Parse(learnSkill.Attributes["id"].Value);
                            skillList.Find(x => x.SkillId == id).CurrentLevel = 1;
                        }
                    }
                }
            }

            // Parsing Additional Data
            foreach (PackFileEntry entry in Resources.XmlReader.Files)
            {
                if (!entry.Name.StartsWith("additionaleffect"))
                {
                    continue;
                }

                XmlDocument document = Resources.XmlReader.GetXmlDocument(entry);
                XmlNodeList levels   = document.SelectNodes("/ms2/level");
                int         skillId  = int.Parse(Path.GetFileNameWithoutExtension(entry.Name));

                List <SkillLevel> skillLevels = new List <SkillLevel>();
                if (skillList.Select(x => x.SkillId).Contains(skillId))
                {
                    foreach (XmlNode level in levels)
                    {
                        int currentLevel = int.Parse(level.SelectSingleNode("BasicProperty").Attributes["level"]?.Value ?? "0");
                        skillLevels = skillList.Find(x => x.SkillId == skillId).SkillLevels;

                        if (skillLevels.Select(x => x.Level).Contains(currentLevel))
                        {
                            skillLevels.Find(x => x.Level == currentLevel).SkillAdditionalData = ParseSkillData(level);
                        }
                    }
                    continue;
                }

                // Adding missing skills from additionaleffect.
                // Since they are many skills that are called by another skill and not from player directly.
                foreach (XmlNode level in levels)
                {
                    int currentLevel = int.Parse(level.SelectSingleNode("BasicProperty").Attributes["level"]?.Value ?? "0");
                    skillLevels.Add(new SkillLevel(currentLevel, ParseSkillData(level)));
                }
                skillList.Add(new SkillMetadata(skillId, skillLevels));
            }
            return(skillList);
        }
Exemplo n.º 6
0
    public override void Init()
    {
        self = GetComponent <MonsterFightUnit>();
        self.OnNoramlAttackFinish += ThinkUseSkill;
        /*普通攻击初始化*/
        normalAttack        = NGUITools.AddChild <NormalAttack>(gameObject);
        normalAttack.attack = Util.GetDic <MsgAttackData, AttackData>()[normalAttackId];
        JsonData castEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.castEffect));

        for (int i = 0; i < castEffectDt.Count; i++)
        {
            normalAttack.castEffectIds.Add((int)castEffectDt[i]);
        }
        JsonData flyEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.flyEffect));

        for (int i = 0; i < flyEffectDt.Count; i++)
        {
            normalAttack.flyEffectIds.Add((int)flyEffectDt[i]);
        }
        JsonData hitEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.hitEffect));

        for (int i = 0; i < hitEffectDt.Count; i++)
        {
            normalAttack.hitEffectIds.Add((int)hitEffectDt[i]);
        }
        normalAttack.mineUnit = self;
        normalAttack.Init();
        /*主动技能初始化*/
        foreach (int normalSkillId in autoSkillsId)
        {
            ActiveSkill normalSkill = NGUITools.AddChild <ActiveSkill>(gameObject);
            normalSkill.normalSkill  = Util.GetDic <MsgNormalSkill, NormalSkill>()[normalSkillId];
            normalSkill.dmgEffectId  = (int)normalSkill.normalSkill.dmgEffect;
            normalSkill.castEffectId = (int)normalSkill.normalSkill.castEffect;
            normalSkill.flyEffectId  = (int)normalSkill.normalSkill.flyEffect;
            normalSkill.hitEffectId  = (int)normalSkill.normalSkill.hitEffect;
            normalSkill.mineUnit     = self;
            int LvUpId = normalSkillId * 100 + 1;
            normalSkill.normalSkillLvUp = Util.GetDic <MsgNormalSkillLvUp, NormalSkillLvUp>()[LvUpId];
            normalSkill.Init();
            MonsterSkill skillCondition = null;
            Util.GetDic <MsgMonsterSkill, MonsterSkill>().TryGetValue(normalSkillId, out skillCondition);
            SkillCondition condition    = SkillCondition.None;
            int            conditionVal = 0;
            float          minCd        = 0;
            float          maxCd        = 0;
            if (skillCondition != null)
            {
                JsonData dt = JsonMapper.ToObject(Util.GetConfigString(skillCondition.condition));
                if (dt.Count == 2)
                {
                    condition    = (SkillCondition)int.Parse(dt[0].ToString());
                    conditionVal = int.Parse(dt[1].ToString());
                }
                JsonData dt_1 = JsonMapper.ToObject(Util.GetConfigString(skillCondition.interval));
                minCd = float.Parse(dt_1[0].ToString());
                maxCd = float.Parse(dt_1[1].ToString());
            }
            ActiveSkillStruct activeSkillStruct = new ActiveSkillStruct();
            activeSkillStruct.autoSkill          = normalSkill;
            activeSkillStruct.autoSkillCondition = skillCondition;
            activeSkillStruct.condition          = condition;
            activeSkillStruct.conditionVal       = conditionVal;
            activeSkillStruct.minCd = minCd;
            activeSkillStruct.maxCd = maxCd;
            autoSkills.Add(activeSkillStruct);
        }
        enabled = false;
    }