Esempio n. 1
0
        /// <summary>
        /// 根据TypeId返回默认Goods
        /// </summary>
        public virtual Goods SetIdFindData(uint _id)
        {
            this.type_idx = _id;

            var goods_info = GoodsHelper.GetGoodsInfo(_id);

            if (goods_info != null)
            {
                this.sub_type = goods_info.sub_type;
                this.effect   = goods_info.effect;
                this.mRawName = goods_info.name;
                this.name     = string.Format("{0}{1}</color>", GoodsHelper.GetGoodsColor(goods_info.color_type), goods_info.name);
                bool is_special_desc = false;
                if (goods_info.effect == "reward_group")//经验和金币类的礼包类的描述需要额外显示
                {
                    List <uint> reward_group_id_array = DBTextResource.ParseArrayUint(goods_info.arg);
                    if (reward_group_id_array != null)
                    {
                        DBRewardGroup db_reward_group = DBManager.Instance.GetDB <DBRewardGroup>();
                        for (int index = 0; index < reward_group_id_array.Count; ++index)
                        {
                            uint reward_group_id = reward_group_id_array[index];
                            DBRewardGroup.DBRewardGroupInfo group_info = db_reward_group.GetOneDBRewardGroupInfo(reward_group_id);
                            if (group_info != null &&
                                (group_info.IsCoinReward || group_info.IsExpReward))
                            {
                                m_group_info    = group_info;
                                is_special_desc = true;
                            }
                        }
                    }
                }
                else if (goods_info.effect == "add_lv_exp")//等级经验丹
                {
                    List <uint> arg_array = DBTextResource.ParseArrayUint(goods_info.arg, ",");
                    if (arg_array != null && arg_array.Count >= 2)
                    {
                        uint level     = arg_array[0]; //直接升级的等级
                        uint reward_id = arg_array[1]; //奖励ID
                        m_level_in_add_lv_exp = level;
                        DBRewardGroup.DBRewardGroupInfo group_info = new DBRewardGroup.DBRewardGroupInfo();
                        group_info.RewardId = reward_id;
                        if (group_info != null &&
                            (group_info.IsCoinReward || group_info.IsExpReward))
                        {
                            m_group_info    = group_info;
                            is_special_desc = true;
                        }
                    }
                }
                string des = goods_info.desc;
                this.src_description = goods_info.desc;
                if (des.CompareTo("") != 0 && is_special_desc == false)
                {
                    if (des[0] == '"')
                    {
                        this.description = des.Substring(1, des.Length - 2);
                    }
                    else
                    {
                        this.description = des;
                    }
                }

                this.arg          = goods_info.arg;
                this.use_lv       = goods_info.use_lv;
                this.use_job      = goods_info.use_job;
                this.use_transfer = goods_info.use_transfer;
                this.gain_text    = goods_info.gain_text;
                this.cd_id        = goods_info.cd_id;
                this.is_mutil_use = goods_info.is_mutil_use == 1 ? true : false;
                this.gain_from    = goods_info.gain_from;
                uint is_quick_int = goods_info.is_quick;
                if (is_quick_int == 0)
                {
                    this.is_quickuse = false;
                }
                else
                {
                    this.is_quickuse = true;
                }

                if (is_quick_int == 2)
                {
                    this.is_quickuse_autoUse = true;
                }
                else
                {
                    this.is_quickuse_autoUse = false;//是否快速使用(有倒计时)
                }
                if (is_quick_int == 3)
                {
                    this.is_quickuse_always = true;
                }
                else
                {
                    this.is_quickuse_always = false;
                }

                this.is_sell_confirmation = goods_info.is_confirmation == 1 ? true : false;
                this.client_use           = goods_info.client_use;
                //暂时没有子类型
                //this.sub_type = DBTextResource.ParseUI(data["sub_type"]);
                this.color_type    = goods_info.color_type;
                this.icon_id       = goods_info.icon_id;
                this.sort_id       = goods_info.sort_id;
                this.sort_top      = goods_info.sort_top;
                this.recycle_price = goods_info.sell_price;

                if (goods_info.is_show == 0)
                {
                    this.tips_show = false;
                }
                else
                {
                    this.tips_show = true;
                }

                this.price_recommend   = goods_info.price_recommend;
                this.price_lower_limit = goods_info.price_lower_limit;
                this.price_upper_limit = goods_info.price_upper_limit;
                this.mktype_1          = goods_info.mktype_1;
                this.mktype_2          = goods_info.mktype_2;
                this.daily_use_limit   = goods_info.daily_use_limit;
                this.guild_wpoint      = goods_info.guild_wpoint;
                this.max_stack         = goods_info.max_stack;
                this.is_display_goods  = goods_info.is_display_goods == 1;
                this.show_step         = goods_info.show_step;
                uint tmpl_is_bind = goods_info.bind;
                if (tmpl_is_bind == 1)
                {
                    mGoodsTmplIsBind = true;
                }
                this.bind                = tmpl_is_bind;
                this.wing_exp            = goods_info.wing_exp;
                this.expire_time_inTmpl  = goods_info.expire_time;
                this.is_precious         = goods_info.is_precious;
                this.discount            = goods_info.discount;
                this.overdue_notice_time = goods_info.overdue_notice_time;
            }
            return(this);
        }
Esempio n. 2
0
        public static string FillTemplateByContentList(string template, string[] param_list)
        {
            if (param_list.Length <= 0)
            {
                return(template);
            }
            if (string.IsNullOrEmpty(template))
            {
                return(string.Empty);
            }

            int index = 0;

            return(mNoticeRegex.Replace(template, new MatchEvaluator(
                                            delegate(Match match)
            {
                string ret = string.Empty;
                if (index >= param_list.Length)
                {
                    return ret;
                }

                string content = param_list [index];
                string target = match.ToString();
                if (target.Length >= 3)
                {
                    target = target.Substring(1, target.Length - 2);
                    EFillType contentType = (EFillType)(int.Parse(target));
                    uint contentNum = 0xffffffff;
                    try
                    {
                        contentNum = Convert.ToUInt32(content);
                    } catch
                    {
                        // Do nothing.
                    }

                    switch (contentType)
                    {
                    // 怪物名字是后端未经过翻译就发过来的,要翻译一下
                    case EFillType.MONSTER_NAME:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;

                    // 玩法场景名字是后端未经过翻译就发过来的,要翻译一下
                    case EFillType.ACTIVITY_SCENE_NAME:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;

                    case EFillType.COLOR_TYPE:
                        ret = GoodsHelper.GetGoodsColor(contentNum);
                        break;

                    case EFillType.CHAT_GOODS_TYPELINK:         // 物品超链接
                        {
                            if (param_list.Length >= 3)
                            {
                                uint playerId = Convert.ToUInt32(param_list[index - 2]);
                                uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                                ulong goods_oid = Convert.ToUInt64(content);

                                uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                                string color_str = GoodsHelper.GetGoodsColor(color_type);
                                string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);

                                uint goodsType = GoodsHelper.GetGoodsType(goods_gid);
                                if (goodsType == GameConst.GIVE_TYPE_EQUIP ||        // 装备
                                    goodsType == GameConst.GIVE_TYPE_RIDE_EQUIP ||   // 坐骑装备
                                    goodsType == GameConst.GIVE_TYPE_MAGIC_EQUIP ||  // 法宝装备
                                    goodsType == GameConst.GIVE_TYPE_DECORATE ||     // 饰品
                                    goodsType == GameConst.GIVE_TYPE_ELEMENT_EP ||   // 元素装备
                                    goodsType == GameConst.GIVE_TYPE_GOD_EQUIP ||    // 神兵
                                    goodsType == GameConst.GIVE_TYPE_ARTIFACT_EP ||  // 神器装备
                                    goodsType == GameConst.GIVE_TYPE_FIVE_ELEM)      // 五行战印
                                {
                                    ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_20"), color_str, goods_name);
                                    ret = ret + "{" + playerId + "," + goods_oid + "," + goods_gid + "})";
                                }
                                else
                                {
                                    ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_21"), color_str, goods_name);
                                    ret = ret + "{" + playerId + "," + goods_gid + "})";
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.CLIENT_GOODS_TYPELINK:       // 客户端物品超链接
                        {
                            uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                            uint goods_oid = contentNum;

                            uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                            string color_str = GoodsHelper.GetGoodsColor(color_type);
                            string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);
                            ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_22"), color_str, goods_name);
                            ret = ret + "{" + content + "})";
                        }
                        break;

                    case EFillType.GOODS_GID:
                        ret = string.Empty;
                        break;

                    case EFillType.HIDE_PLAYER_ID:
                        ret = string.Empty;
                        break;

                    case EFillType.GOODS_GID_NEW:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint playerId = Convert.ToUInt32(param_list[index - 1]);
                                uint goods_gid = Convert.ToUInt32(param_list[index]);

                                uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                                string color_str = GoodsHelper.GetGoodsColor(color_type);
                                string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);
                                ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_21"), color_str, goods_name);
                                ret = ret + "{" + playerId + "," + goods_gid + "})";
                            }
                            else
                            {
                                ret = content;
                            }

                            break;
                        }

                    case EFillType.PET_ID:     // 守护ID(显示带守护品质颜色的守护名字)
                        {
                            uint pet_id = Convert.ToUInt32(content);
                            var pet_info = DBManager.Instance.GetDB <DBPet>().GetOnePetInfo(pet_id);
                            if (pet_info != null)
                            {
                                string color_str = GoodsHelper.GetGoodsColor(pet_info.Quality + 1);    //守护品质颜色和物品相差1
                                string actor_name = ActorHelper.GetActorName(pet_info.Actor_id);
                                ret = string.Format("{0}{1}</color>", color_str, actor_name);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.TITLE_ID:
                        {
                            uint title_id = Convert.ToUInt32(content);
                            var title_info = DBManager.Instance.GetDB <DBHonor>().GetData(title_id);
                            if (title_info != null)
                            {
                                string color_str = GoodsHelper.GetGoodsColor(title_info.Quality);
                                string title_name = title_info.Name;
                                ret = string.Format("{0}{1}</color>", color_str, title_name);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.QUAL_WORD:
                        {
                            uint qual = Convert.ToUInt32(content);
                            string color_str_name = GoodsHelper.GetGoodsColorName(qual);
                            string color_str = GoodsHelper.GetGoodsColor(qual);
                            ret = string.Format("{0}{1}</color>", color_str, color_str_name);
                        }
                        break;

                    case EFillType.TRANSFER_LV:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint init_vocation = Convert.ToUInt32(param_list[index]);
                                uint transfer_lv = Convert.ToUInt32(param_list[index - 1]);
                                object[] param = { transfer_lv, init_vocation };
                                System.Type[] returnType = { typeof(string) };
                                object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "TransferMgr_GetVocationName", param, returnType);
                                if (objs != null && objs.Length > 0 && objs[0] != null)
                                {
                                    ret = (string)objs[0];
                                }
                                else
                                {
                                    ret = content;
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.InitVocation:
                        ret = string.Empty;
                        break;

                    case EFillType.SHOW_TYPE_TO_NAME:     //外显系统ID =>外显系统名字
                        {
                            uint show_type = Convert.ToUInt32(param_list[index]);
                            object[] param = { show_type };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetShowName", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_PARAM:    //外显系统ID => 与25一起使用,组成外显系统的外观名字
                        {
                            ret = string.Empty;
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_FACADE_ID:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint facade_id = Convert.ToUInt32(param_list[index]);
                                uint show_type = Convert.ToUInt32(param_list[index - 1]);
                                object[] param = { show_type, facade_id };
                                System.Type[] returnType = { typeof(string) };
                                object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetFacadeName", param, returnType);
                                if (objs != null && objs.Length > 0 && objs[0] != null)
                                {
                                    ret = (string)objs[0];
                                }
                                else
                                {
                                    ret = content;
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_SYS_ID:       //外显系统ID =>外显系统ID
                        {
                            uint show_type = Convert.ToUInt32(param_list[index]);
                            object[] param = { show_type };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetSysIdStr", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.FASHION_NAME:       //时装
                        {
                            uint fashionId = Convert.ToUInt32(param_list[index]);
                            object[] param = { fashionId };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "FashionManager_GetFashionNameWithColor", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.MALL_NAME:     //商城名字
                        {
                            uint mall_id = Convert.ToUInt32(param_list[index]);
                            var mall_tmpl = xc.DBManager.Instance.GetDB <DBMallType>().GetOneItem(mall_id);
                            if (mall_tmpl != null)
                            {
                                //string color_str = GoodsHelper.GetGoodsColor(mall_tmpl);
                                string tmall_name = mall_tmpl.Name;
                                //ret = string.Format("{0}{1}</color>", color_str, tmall_name);
                                ret = tmall_name;
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.ESCORT_TASK_ID:     //护送任务的id
                        {
                            uint taskId = Convert.ToUInt32(param_list[index]);
                            TaskDefine taskDefine = TaskDefine.MakeDefine(taskId);
                            if (taskDefine != null)
                            {
                                ret = taskDefine.GetFollowNpcName(0);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.INSTANCE_ID:     //副本id
                        {
                            uint instanceId = Convert.ToUInt32(param_list[index]);
                            DBInstance.InstanceInfo instanceInfo = DBInstance.Instance.GetInstanceInfo(instanceId);
                            if (instanceInfo != null)
                            {
                                ret = instanceInfo.mName;
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.GODWARE_ID:    //神器id
                        {
                            uint god_ware_id = Convert.ToUInt32(param_list[index]);
                            object[] param = { god_ware_id };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "GodWareManager_GetGodWareName", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.TIMEFORMAT:
                        int time = Convert.ToInt32(param_list[index]);
                        string strShowTime = CommonTool.SecondsToStr_2(time);
                        ret = strShowTime;
                        break;

                    case EFillType.BIG_PACKET:
                        uint bigNum = Convert.ToUInt32(param_list[index]);
                        if (bigNum != 0)
                        {
                            //ret = string.Format("{0}个大红包,", bigNum);
                            ret = string.Format(xc.DBConstText.GetText("RAIN_RED_PACKET_BIG"), bigNum);
                        }
                        else
                        {
                            ret = "";
                        }
                        break;

                    case EFillType.SMALL_PACKET:
                        uint smallNum = Convert.ToUInt32(param_list[index]);
                        if (smallNum != 0)
                        {
                            //ret = string.Format("{0}个小红包,", smallNum);
                            ret = string.Format(xc.DBConstText.GetText("RAIN_RED_PACKET_SMALL"), smallNum);
                        }
                        else
                        {
                            ret = "";
                        }
                        break;

                    case EFillType.MARKET_ID:
                        {
                            uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                            uint goods_oid = contentNum;

                            uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                            string color_str = GoodsHelper.GetGoodsColor(color_type);
                            string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);

                            // 【click={0}[{1}]</color>】(marketGoodsTips=
                            ret = string.Format(xc.TextHelper.GetConstText("GAME_CHAT_CLICK_MARKET_GOODS"), color_str, goods_name);
                            ret = ret + "{" + content + "})";
                        }
                        break;

                    case EFillType.CONTROL_ID:
                        var id = Convert.ToInt32(param_list[index]);
                        ret = SpanServerManager.Instance.GetServerNameByControlServerId((uint)id);
                        break;

                    case EFillType.CHANNEL_ID:
                        ret = ChannelHelper.GetChannelName(param_list[index]);
                        break;

                    default:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;
                    }
                }

                index++;
                return ret;
            }
                                            )));
        }
Esempio n. 3
0
        public string GetSubAttrDesc(EquipAttrData attrData, string replace_str, uint sub_attr_id, out uint color, params uint[] values)
        {
            color = 0;
            string colorStr = string.Empty;
            string attr     = "";

            EquipSubAttrData data = GetSubAttrData(sub_attr_id);

            if (data != null)
            {
                List <string> des_value = new List <string>();
                for (int i = 0; i < data.DesType.Count; i++)
                {
                    for (int j = 0; j < attrData.ColorType.Count; j++)
                    {
                        var valuerange = attrData.ColorType[j];
                        if (values[i] >= valuerange.Min && values[i] <= valuerange.Max)
                        {
                            color    = (uint)j;
                            colorStr = GoodsHelper.GetGoodsColor((uint)j);//对应就是0~4品质
                            break;
                        }
                    }
                    if (i < values.Length)
                    {
                        switch (data.DesType[i])
                        {
                        case 0:
                        {
                            string val = values[i].ToString();

                            des_value.Add(val);
                        }
                        break;

                        case 1:
                        {
                            string val = (values[i] / ActorHelper.UnitConvert).ToString("0.00");
                            val = ActorUtils.Instance.TrimFloatStr(val);
                            des_value.Add(val);
                        }
                        break;

                        case 2:
                        {
                            string val_noSign = (values[i] / ActorHelper.DisplayPercentUnitConvert).ToString("0.00");
                            val_noSign = ActorUtils.Instance.TrimFloatStr(val_noSign);
                            string val = val_noSign + "%";
                            des_value.Add(val);
                        }
                        break;
                        }
                    }
                }
                string des_str = data.Des;
                if (replace_str != null && replace_str.Length > 0)
                {
                    for (int index = 0; index < des_value.Count; ++index)
                    {
                        des_str = des_str.Replace("{" + index.ToString() + "}", replace_str + "{" + index.ToString() + "}");
                    }
                }
                if (des_value.Count > 0)
                {
                    attr = string.Format(des_str, des_value.ToArray());
                }
            }
            if (colorStr.CompareTo(string.Empty) != 0)
            {
                attr = colorStr + attr + "</color>";
            }
            return(attr);
        }