/// <summary> /// 是否禁止使用道具 /// </summary> public bool ForbidUseGoods(uint goodsId) { uint goodsType = GoodsHelper.GetGoodsType(goodsId); uint goodsSubType = GoodsHelper.GetGoodsSubType(goodsId); return(DBInstanceTypeControl.Instance.ForbidUseGoods(InstanceManager.Instance.InstanceType, InstanceManager.Instance.InstanceSubType, goodsType, goodsSubType)); }
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; } ))); }
Dictionary <string, bool> mGoodsSettingInfoConditionsCache = null; // 条件缓存 bool CheckMeetGoodsSettingInfoCondition(uint goodsId, HookGoodsSettingInfo hookGoodsSettingInfo, Dictionary <uint, HookGoodsSettingInfo> hookGoodsSettingInfos, string cacheKeyPrefix) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(cacheKeyPrefix); sb.Append("_"); sb.Append(goodsId); sb.Append("_"); sb.Append(hookGoodsSettingInfo.Id); string cacheKey = sb.ToString(); if (mGoodsSettingInfoConditionsCache == null) { mGoodsSettingInfoConditionsCache = new Dictionary <string, bool>(); mGoodsSettingInfoConditionsCache.Clear(); } if (mGoodsSettingInfoConditionsCache.ContainsKey(cacheKey) == true) { return(mGoodsSettingInfoConditionsCache[cacheKey]); } bool ret = false; switch (hookGoodsSettingInfo.Type) { case HookGoodsSettingInfo.EType.OtherAll: { Dictionary <uint, HookGoodsSettingInfo> otherAllHookGoodsSettingInfos = new Dictionary <uint, HookGoodsSettingInfo>(); otherAllHookGoodsSettingInfos.Clear(); foreach (HookGoodsSettingInfo otherHookGoodsSettingInfo in hookGoodsSettingInfos.Values) { if (otherHookGoodsSettingInfo.Type != HookGoodsSettingInfo.EType.OtherAll) { otherAllHookGoodsSettingInfos.Add(otherHookGoodsSettingInfo.Id, otherHookGoodsSettingInfo); } } ret = true; foreach (HookGoodsSettingInfo otherHookGoodsSettingInfo in otherAllHookGoodsSettingInfos.Values) { if (CheckMeetGoodsSettingInfoCondition(goodsId, otherHookGoodsSettingInfo, otherAllHookGoodsSettingInfos, "other_all_hook_goods_setting") == true) { ret = false; break; } } break; } case HookGoodsSettingInfo.EType.GoodsIds: { if (hookGoodsSettingInfo.Params.Contains(goodsId) == true) { ret = true; break; } break; } case HookGoodsSettingInfo.EType.GoodsType: { uint goodsType = GoodsHelper.GetGoodsType(goodsId); uint goodsSubType = GoodsHelper.GetGoodsSubType(goodsId); if (hookGoodsSettingInfo.Params.Count >= 2) { if (goodsType == hookGoodsSettingInfo.Params[0] && goodsSubType == hookGoodsSettingInfo.Params[1]) { ret = true; break; } } break; } case HookGoodsSettingInfo.EType.EquipCertainColor: { uint goodsType = GoodsHelper.GetGoodsType(goodsId); if (goodsType == GameConst.GIVE_TYPE_EQUIP) { uint color = GoodsHelper.GetGoodsColorTypeByTypeId(goodsId); if (color == hookGoodsSettingInfo.Params[0]) { ret = true; break; } } break; } case HookGoodsSettingInfo.EType.EquipUponCertainColor: { uint goodsType = GoodsHelper.GetGoodsType(goodsId); if (goodsType == GameConst.GIVE_TYPE_EQUIP) { uint color = GoodsHelper.GetGoodsColorTypeByTypeId(goodsId); if (color >= hookGoodsSettingInfo.Params[0]) { ret = true; break; } } break; } case HookGoodsSettingInfo.EType.EquipPoses: { uint pos = xc.Equip.EquipHelper.GetEquipPosByGid(goodsId); foreach (uint param in hookGoodsSettingInfo.Params) { if (pos == param) { ret = true; break; } } break; } default: break; } mGoodsSettingInfoConditionsCache.Add(cacheKey, ret); return(ret); }
/// <summary> /// 拷贝指引的目标控件 /// </summary> public void CopyTargetObj() { if (TargetObject == null) { return; } CopyObj = UnityEngine.GameObject.Instantiate(TargetObject) as GameObject; var toggle = CopyObj.GetComponent <Toggle>(); if (toggle != null) { toggle.group = null; } CopyTrans = CopyObj.transform; // 需要特殊处理的MonoBehaviour var spec_list = SGameEngine.Pool <MonoBehaviour> .List.New(); // 把非UI控件的MonoBehaviour销毁掉 var remove_list = SGameEngine.Pool <MonoBehaviour> .List.New(); var db_guide_copy_behavior = DBManager.Instance.GetDB <DBGuideCopyBehavior>(); foreach (var com in CopyObj.GetComponentsInChildren <MonoBehaviour>(true)) { // 处理特殊的组件 TargetModelInfo target_model_info = com as TargetModelInfo; if (target_model_info != null) { spec_list.Add(target_model_info); continue; } // 因为UIItemNewSlot采用了延迟加载图标,直接拷贝会图标丢失,需要把UIItemNewSlot也拷贝进来并进行加载工作 UIItemNewSlot slot = com as UIItemNewSlot; if (slot != null) { UIItemNewSlot source_slot = TargetObject.GetComponentInChildren <UIItemNewSlot>(); if (source_slot != null) { slot.ItemInfo = source_slot.ItemInfo; slot.SetUI(); if (slot.ItemInfo != null && GoodsHelper.GetGoodsType(slot.ItemInfo.type_idx) == GameConst.GIVE_TYPE_SOUL) { slot.CanShowCircleBkg = true; slot.SetColor(false); slot.SetBgImageVisiable(false); slot.SetEffectRootVisiable(false); } } continue; } // ui控件的基类 if (com == null || com is ICanvasElement || com is Selectable) { continue; } // 其他需要添加的组件 string class_name = com.GetType().Name; if (db_guide_copy_behavior.ContainType(class_name)) { continue; } //有Alpha渐变时直接设为不透明 TweenAlpha tween = com as TweenAlpha; if (tween != null) { tween.value = 1; } // 剩余的组件添加到remove_list remove_list.Add(com); } for (int i = remove_list.Count - 1; i >= 0; i--) { //包含序列帧特效的GameObject直接删掉,因为有特效重叠不同步的问题,物品除外 if (remove_list[i] is UGUIFrameAnimation) { if (remove_list[i].transform.parent != null && remove_list[i].transform.parent.parent != null) { if (remove_list[i].transform.parent.parent.GetComponent <UIItemNewSlot>() == null) { UnityEngine.Object.DestroyImmediate(remove_list[i].gameObject); } } } else { UnityEngine.Object.DestroyImmediate(remove_list[i]); } } SGameEngine.Pool <MonoBehaviour> .List.Free(remove_list); var canvas = CopyObj.GetComponent <Canvas>(); if (canvas != null) { UnityEngine.Object.DestroyImmediate(canvas); } CopyObj.SetActive(false); CopyTrans.SetParent(Wnd.TargetTmpRoot); var local_pos = CopyTrans.localPosition; local_pos.z = 0f; CopyTrans.localPosition = local_pos; RectTransform copy_trans = CopyTrans.GetComponent <RectTransform>(); RectTransform traget_trans = TargetObject.GetComponent <RectTransform>(); UGUIMath.SetWidgetSize(copy_trans, traget_trans); CopyObj.SetActive(true); // 可能traget_trans的父亲节点有缩放 var rect_corner = new Vector3[4]; copy_trans.GetWorldCorners(rect_corner); float copy_rect_size_x = rect_corner[2].x - rect_corner[0].x; traget_trans.GetWorldCorners(rect_corner); float target_size_x = rect_corner[2].x - rect_corner[0].x; float scale = 1; if (copy_rect_size_x != 0) { scale = target_size_x / copy_rect_size_x; } Vector3 ori_scale = CopyTrans.localScale; CopyTrans.localScale = new Vector3(ori_scale.x * scale, ori_scale.y * scale, ori_scale.z * scale); for (int i = spec_list.Count - 1; i >= 0; i--) { var com = spec_list[i]; //StartLoadModel 函数中播放模型动作在object隐藏时会不生效,需延后调用 TargetModelInfo target_model_info = com as TargetModelInfo; if (target_model_info != null) { target_model_info.StartLoadModel(); } } SGameEngine.Pool <MonoBehaviour> .List.Free(spec_list); }
public static Goods Create(uint typeId, Net.PkgGoodsInfo info) { uint mainType = GoodsHelper.GetGoodsType(typeId); return(Create(mainType, typeId, info)); }