示例#1
0
    public static void CreateGongfaItem(GongfaStaticData gongfa, List <ItemStaticData> item_list, ItemSubType sub_type)
    {
        StringBuilder des = new StringBuilder();

        if (gongfa is HeartGongfaStaticData)
        {
            HeartGongfaStaticData gf = (HeartGongfaStaticData)gongfa;
            des.AppendFormat("道点消耗:{0}", gf.need_daodian);
        }
        else if (gongfa is SkillGongfaStaticData)
        {
            SkillGongfaStaticData gf = (SkillGongfaStaticData)gongfa;
            des.AppendFormat("技能冷却:{0}", gf.cool);
            des.AppendLine();
            des.AppendFormat("施法消耗:{0}", gf.cost);
        }
        des.AppendLine();
        des.AppendLine("——————————————————");

        bool isSkill = true;

        for (int i = 0; i < gongfa.attr_id.Length; i++)
        {
            var            attr_id        = gongfa.attr_id[i];
            GongfaAttrData main_attr_data = GongfaAttrConfig.GetAttrConfig(attr_id);
            if (!main_attr_data.isSkill && isSkill)
            {
                isSkill = false;
                des.AppendLine("<color=#E28225FF>装备后可获得以下属性</color>");
            }
            if (isSkill)
            {
                des.AppendLine(DesFormat(main_attr_data.des, gongfa.attr_value[i]));
            }
            else
            {
                des.AppendLine(" " + DesFormat(main_attr_data.des, gongfa.attr_value[i]));
            }
        }
        des.AppendLine("——————————————————");
        for (int i = 0; i < gongfa.ex_id.Length; i++)
        {
            GongfaAttrData congfa_attr_data = GongfaAttrConfig.GetAttrConfig(gongfa.ex_id[i]);
            des.AppendFormat(" <size=10>{1}</size>:<color=#{0}>", GameConst.item_color_str[gongfa.ex_color[i]], GameConst.attr_level_name[i]);
            des.Append(DesFormat(congfa_attr_data.des, gongfa.ex_values[i]));
            des.AppendLine("</color>");
        }
        des.AppendLine("——————————————————");
        if (gongfa.attr_condition[0].Length == 1)
        {
            RoleAttrConfig[] attribute_config = RoleAttrConfigData.GetAttrConfig();
            des.AppendFormat("学习条件:{0}达到{1}", attribute_config[(int)gongfa.attr_condition[0][0]].name, gongfa.value_condition[0]);
        }
        else
        {
            des.AppendFormat("任意一项战斗资质达到{0}", gongfa.value_condition[0]);
        }



        int item_static_id = item_list.Count;
        var item           = new ItemStaticData()
        {
            id       = item_static_id,
            type     = ItemType.Gongfa,
            sub_ype  = sub_type,
            price    = gongfa.price,
            maxcount = 1,
            param    = new int[] { gongfa.id },

            name  = gongfa.name,
            icon  = ItemSubType.Magic - sub_type,
            color = gongfa.color,
            level = gongfa.level,

            des         = des.ToString(),
            attributes  = null,
            attr_values = null,
        };

        item_list.Add(item);
    }
示例#2
0
    /// <summary>
    /// 更新属性 重新计算装备增加的属性
    /// </summary>
    public void UpdateAttr()
    {
        int count = attribute.Length;

        if (definitive_attribute == null || definitive_max_attribute == null)
        {
            definitive_attribute     = new int[count];
            definitive_max_attribute = new int[count];
            for (int i = 0; i < count; i++)
            {
                definitive_attribute[i]     = attribute[i];
                definitive_max_attribute[i] = max_attribute[i];
            }
        }

        int old_ride = GetAttr(RoleAttribute.ride_id);
        int new_ride = -1;

        // 记录更新属性
        int[] max_value = new int[count];
        for (int i = 0; i < count; i++)
        {
            max_value[i] = max_attribute[i];
        }

        // 计算装备增加的属性
        for (int i = 0; i < equip_items.Length; i++)
        {
            int item_id = equip_items[i];
            if (item_id == -1)
            {
                continue;
            }
            ItemData       item        = GameData.instance.all_item[item_id];
            ItemStaticData static_data = GameData.instance.item_static_data[item.static_id];
            for (int j = 0; j < static_data.attributes.Length; j++)
            {
                int attr = (int)static_data.attributes[j];
                max_value[attr] += static_data.attr_values[j];
            }
            if (static_data.sub_ype == ItemSubType.Ride)
            {
                new_ride = static_data.param[0];
            }
        }
        // 计算功法加的属性
        int daodian = 0; // 记录功法使用的道点
        List <GongfaData> gongfas = new List <GongfaData>(heart_gongfa);

        gongfas.Add(attack_gongfa);
        gongfas.Add(skill_gongfa);
        gongfas.Add(body_gongfa);
        gongfas.Add(magic_gongfa);
        for (int i = 0; i < gongfas.Count; i++)
        {
            GongfaData gongfa = gongfas[i];
            if (gongfa != null)
            {
                GongfaStaticData static_gongfa = GetGongfaStaticData(gongfa);
                for (int j = 0; j < static_gongfa.attr_id.Length; j++)
                {
                    GongfaAttrData attr_data = GongfaAttrConfig.GetAttrConfig(static_gongfa.attr_id[j]);
                    if (!attr_data.isSkill)
                    {
                        int value = gongfa.attr_value[j][0];
                        max_value[(int)attr_data.attr] += value;
                    }
                }
                for (int j = 0; j < static_gongfa.ex_id.Length; j++)
                {
                    GongfaAttrData attr_data = GongfaAttrConfig.GetAttrConfig(static_gongfa.ex_id[j]);
                    if (!attr_data.isSkill)
                    {
                        int value = gongfa.ex_values[j][0];
                        max_value[(int)attr_data.attr] += value;
                    }
                }
                if (static_gongfa is HeartGongfaStaticData)
                {
                    daodian += ((HeartGongfaStaticData)static_gongfa).need_daodian;
                }
            }
        }

        RoleAttrConfig[] attribute_config = RoleAttrConfigData.GetAttrConfig();
        for (int i = 0; i < count; i++)
        {
            float rate = definitive_attribute[i] == definitive_attribute[i] ? 1 : definitive_attribute[i] * 1f / definitive_max_attribute[i];
            if (attribute_config[i].type == RoleAttrShowType.FixedMinMax)
            {
                definitive_max_attribute[i] = max_value[i];
                continue;
            }
            else if (attribute_config[i].type != RoleAttrShowType.MinMax)
            {
                rate = 1;
            }
            definitive_max_attribute[i] = max_value[i];
            definitive_attribute[i]     = (int)(max_value[i] * rate);
        }
        definitive_attribute[(int)RoleAttribute.daodian] = daodian; // 修改当前使用的道点

        EventManager.SendEvent(EventTyp.AttrChange, this);          // 通知属性变更

        if (old_ride != new_ride)
        {
            SetAttrebuteValue(RoleAttribute.ride_id, new_ride);
            EventManager.SendEvent(EventTyp.ChangeRide, this); // 通知坐骑变更
        }
    }