コード例 #1
0
    public void OnAddDataToSkillStateDic()
    {
        var allSkillStates = ConfigManager.GetAll <SkillToStateInfo>();

        m_currentSkillStates.Clear();
        m_currentSkillStates = allSkillStates.FindAll(p =>
        {
            var skill_info = GetSkillInfoByID(p.skillId);
            if (!skill_info)
            {
                return(false);
            }
            var propItemInfo = moduleEquip.weapon?.GetPropItem();
            if (propItemInfo != null)
            {
                var type       = (WeaponSubType)propItemInfo.subType;
                var weaponAttr = ConfigManager.Get <WeaponAttribute>(moduleEquip.weapon.itemTypeId);
                if (!weaponAttr)
                {
                    return(false);
                }
                if (skill_info.protoId == modulePlayer.proto && skill_info.weaponType.Contains(type) && (p.elmentType == weaponAttr.elementType || p.elmentType == 0))
                {
                    return(true);
                }
            }

            return(false);
        });

        m_skillStateLevelDic.Clear();
        m_stateToSkill.Clear();

        List <string> states = new List <string>();

        for (int i = 0; i < m_currentSkillStates.Count; i++)
        {
            states.Clear();
            if (m_currentSkillStates[i].stateNames == null || m_currentSkillStates[i].addStates == null)
            {
                continue;
            }
            states.AddRange(m_currentSkillStates[i].stateNames);
            states.AddRange(m_currentSkillStates[i].addStates);

            for (int k = 0; k < states.Count; k++)
            {
                var stateID = CreatureStateInfo.NameToID(states[k]);
                if (!m_skillStateLevelDic.ContainsKey(stateID))
                {
                    var data = allSkillDatas.Find(p => p.pskill.skillId == m_currentSkillStates[i].skillId);
                    if (data == null)
                    {
                        Logger.LogError("can not Find id=={0} in config_upskillInfo ,please check out config_skillInfo", m_currentSkillStates[i].skillId);
                        continue;
                    }

                    m_skillStateLevelDic.Add(stateID, data.pskill.level);
                    m_stateToSkill.Add(stateID, m_currentSkillStates[i].skillId);
                }
                else
                {
                    Logger.LogError("config_skillToState have same state={0} in different skillID", states[k]);
                }
            }
        }
    }
コード例 #2
0
    public double[] GetCurrentSkillDamge(int skillId, int level)
    {
        double[]        defaultDouble = new double[] { 0, 0 };
        WeaponAttribute attr          = ConfigManager.Get <WeaponAttribute>(moduleEquip.weapon.itemTypeId);

        if (!attr)
        {
            return(defaultDouble);
        }
        SkillToStateInfo states = m_currentSkillStates.Find(p => p.skillId == skillId && (p.elmentType == attr.elementType || p.elmentType == 0));

        if (!states || states.stateNames == null || states.stateNames.Length < 1)
        {
            return(defaultDouble);
        }

        double damage = 0;
        double spcail = 0;
        int    weapon = moduleEquip.weapon.GetPropItem().subType;

        for (int i = 0; i < states.stateNames.Length; i++)
        {
            int stateID = CreatureStateInfo.NameToID(states.stateNames[i]);
            var _state  = StateOverrideInfo.GetOverrideState(weapon, stateID, level);

            //int reliveID = CreatureStateInfo.NameToID(ReLiveState);
            //if (reliveID == stateID)
            //{
            //    reliveSkillId = states.skillId;
            //    if (_state.buffs.Length > 0)
            //    {
            //        defaultDouble[0] = (double)_state.buffs[0].duration / 1000;
            //        return defaultDouble;
            //    }
            //}

            for (int j = 0; j < _state.sections.Length; j++)
            {
                if (_state.sections[j].attackBox.isEmpty)
                {
                    continue;
                }

                var attack = AttackInfo.Get(_state.sections[j].attackBox.attackInfo);
                if (attack == null || attack.isIgnoreDamge)
                {
                    continue;
                }
                if (attack.execution)
                {
                    spcail += attack.damage;
                    continue;
                }
                damage += attack.damage;
            }

            int fly = _state.flyingEffects.Length;
            if (fly > 0)
            {
                for (int k = 0; k < fly; k++)
                {
                    var effect = ConfigManager.Get <FlyingEffectInfo>(_state.flyingEffects[k].effect);
                    if (effect == null)
                    {
                        continue;
                    }

                    //统计hiteffect的伤害,必须满足subeffect中不包含相同的effectid
                    if (!effect.hitEffect.isEmpty)
                    {
                        StateMachineInfo.FlyingEffect exist = StateMachineInfo.FlyingEffect.empty;
                        if (effect.subEffects != null && effect.subEffects.Length > 0)
                        {
                            exist = effect.subEffects.Find(p => p.effect == effect.hitEffect.effect);
                        }

                        if (exist.isEmpty)
                        {
                            double[] hit = HitEffectDamage(effect.hitEffect);
                            damage += hit[0];
                            spcail += hit[1];
                        }
                    }

                    if (effect.subEffects != null && effect.subEffects.Length > 0)
                    {
                        double[] sub = SubEffectDamage(effect.subEffects);
                        damage += sub[0];
                        spcail += sub[1];
                    }

                    for (int p = 0; p < effect.sections.Length; p++)
                    {
                        if (effect.sections[p].attackBox.isEmpty)
                        {
                            continue;
                        }

                        var attack = AttackInfo.Get(effect.sections[p].attackBox.attackInfo);
                        if (attack == null || attack.isIgnoreDamge)
                        {
                            continue;
                        }
                        if (attack.execution)
                        {
                            spcail += attack.damage;
                            continue;
                        }
                        damage += attack.damage;
                    }
                }
            }
        }
        double _d = UpSkillInfo.GetOverrideDamage(skillId, level) * (1 + modulePlayer.GetSkillDamageAddtion(skillId));

        defaultDouble[0] = damage * (1 + _d);
        defaultDouble[1] = spcail * (1 + _d);
        return(defaultDouble);
    }
コード例 #3
0
 /// <summary>
 /// 获取指定状态对应的技能
 /// </summary>
 /// <returns></returns>
 public int GetStateSkill(string state)
 {
     return(GetStateSkill(CreatureStateInfo.NameToID(state)));
 }