public void DeleteState(E_StateId id) { // 遍历状态列表,如果存在则移除 int length = states.Count; for (int i = 0; i < length; i++) { if (states[i].Id == id) { states.Remove(states[i]); return; } } LogManager.Error("删除错误: 删除状态[{0}]失败,因为不存在于列表中 ", id); }
public override I_PoolObjectAbility Create() { // 加载 GameObject go = ResManager.instance.LoadPrefab(FactoryName); PoolDefaultRectTransform po = go.GetComponent<PoolDefaultRectTransform>(); if (po == null) { po = go.AddComponent<PoolDefaultRectTransform>(); LogManager.Error("这种形式的创建,会导致最后Pop的时候会有困难[{0}]", _factoryName); } po.SetName(_factoryName); po.SetParent(_factoryGoRoot.transform); return po; }
public void Set(float all_time, float fade_in, float fade_out) { _all_time = all_time; _fade_out = _all_time - fade_out; _fade_in = fade_in; _start = true; if (_fade_out < 0) { LogManager.Error("淡入淡出效果参数异常.All_Time:[{0}],Fade_In:[{1}],Fade_Out:[{2}]", all_time, fade_in, fade_out); _start = false; } if (MathHelper.IsZero(fade_in) && MathHelper.IsZero(fade_out)) { _start = false; } }
public virtual T Pop <T>(string prefabName) where T : class, I_PoolObjectAbility { PoolBase poolBase; _map.TryGetValue(prefabName, out poolBase); if (poolBase == null) { poolBase = GetDefaultFactory(prefabName); } I_PoolObjectAbility po = poolBase.Pop(); T t = po as T; if (t == null) { LogManager.Error("po:[{0}],[{1}]", po, prefabName); } return(t); }
public static void _internal_int_set_value(string value, FieldInfo fieldInfo, BaseCsv csv) { try { if (string.IsNullOrEmpty(value)) { fieldInfo.SetValue(csv, 0); } else { fieldInfo.SetValue(csv, Int32.Parse(value)); } } catch (Exception e) { LogManager.Error("[{0}],[{1}]", value, e.Message); } }
public virtual bool Push(I_PoolObjectAbility po) { PoolBase poolBase; if (string.IsNullOrEmpty(po.ObjectName)) { LogManager.Error("名字为空"); return(false); } _map.TryGetValue(po.ObjectName, out poolBase); if (poolBase == null) { LogManager.Error("子类缓存管理不存在"); return(false); } return(poolBase.Push(po)); }
public BaseCsvInfo(string filePath) { _originalFilePath = filePath; _originalFileName = Path.GetFileNameWithoutExtension(_originalFilePath); _className = CnfHelper.NormalizeName(_originalFileName) + "Cnf"; _classPath = CnfConst.cnf_path + _className + ".cs"; string text = FileHelper.ReadAllText(_originalFilePath); string[] lines = text.ToStrs(StringHelper._splitHuanhang); if (lines.Length < 4) { LogManager.Error("配置文件出错", _originalFilePath); return; } string[] dess = lines[0].ToStrs(StringHelper._splitDouhao); string[] types = lines[1].ToStrs(StringHelper._splitDouhao); string[] names = lines[2].ToStrs(StringHelper._splitDouhao); string[] rules = lines[3].ToStrs(StringHelper._splitDouhao); if (dess.Length != types.Length || dess.Length != names.Length) { LogManager.Error("配置文件出错", _originalFilePath); return; } _propDes.AddRange(dess); _propType.AddRange(types); _propName.AddRange(names); _propRule.AddRange(rules); int length = lines.Length; for (int i = 4; i < length; i++) { if (string.IsNullOrEmpty(lines[i])) { continue; } string[] contents = lines[i].ToStrs(StringHelper._splitDouhao); _datas.Add(new List <string>(contents)); } }
/// <summary> /// 提供一个方法遍历所有value值 /// </summary> public static void ForeachValue <TKey, TValue>(this Dictionary <TKey, TValue> dic, Action <TValue> action, int maxCount = 1000) { if (action == null) { return; } var enumerator = dic.GetEnumerator(); int i = 0; while (enumerator.MoveNext() && i++ < maxCount) { action(enumerator.Current.Value); } if (i >= maxCount) { LogManager.Error("Dictionary Foreach Error"); } }
/// <summary> /// 把资源放到池子中 /// </summary> /// <param name="obj"></param> /// <returns></returns> public virtual bool Push(I_EntityLife obj) { if (obj == null) { LogManager.Error("对象池 [?]回收null的资源错误"); return(false); } if (!obj.IsUse) { LogManager.Error("对象池回收资源错误[{0}]错误,正在使用中", obj.ObjectName); return(false); } obj.IsUse = false; _in.Add(obj); _out.Remove(obj); obj.OnPush(); return(true); }
public override I_PoolObjectAbility Create() { GameObject go = ResManager.instance.LoadPrefab(FactoryName); if (go == null) { LogManager.Error("缓存池_加载[{0}]失败", _factoryName); return(null); } PoolDefaultGameObject po = go.GetComponent <PoolDefaultGameObject>(); if (po == null) { po = go.AddComponent <PoolDefaultGameObject>(); LogManager.Error("这种形式的创建,会导致最后Pop的时候会有困难[{0}]", _factoryName); } po.SetName(FactoryName); po.SetParent(_factoryGoRootTrans); return(po); }
public void OnUpdate(float dt) { // 通过时间来触发事件, //SkillContainerTest.OnUpdate(dt); if (_curr_sequece == null) { return; } _curr_sequece.OnUpdate(dt); // TODO test code float curr_time = TimeModule.RealtimeSinceStartup; if (curr_time - _last_time > 15.0) { LogManager.Error("技能释放错误,超过时间,Skill:{0}", _curr_sequece); _last_time = TimeModule.RealtimeSinceStartup; } }
public IEnumerator BeginConnection() { try { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _socket.BeginConnect(NetworkConst.ip_address, NetworkConst.ip_port, _finish_connect, null); } catch (Exception ex) { LogManager.Error(ex.StackTrace); yield break; } yield return(CoroutineConst.GetWaitForSeconds(NetworkConst.CONNECT_TIME_OUT)); if (!_socket.Connected) { LogManager.Error("Client Connect Time Out..."); CloseConnection(); } _is_keep_alive = _socket.Connected; }
/// <summary> /// 解析(1,1,1 或11.1,10,2)为vector3 /// </summary> /// <param name="strVector3"></param> /// <param name="splitStr"></param> /// <returns></returns> public static Vector3 StringToVector3(string strVector3, params char[] splitStr) { Vector3 ret = Vector3.zero; if (!string.IsNullOrEmpty(strVector3)) { var strArr = strVector3.Split(splitStr); if (strArr.Length == 3) { float.TryParse(strArr[0].Trim(), out ret.x); float.TryParse(strArr[1].Trim(), out ret.y); float.TryParse(strArr[2].Trim(), out ret.z); } else { LogManager.Error("str length not 3"); } } else { LogManager.Error("str length not 3"); } return ret; }
public static T FindData <T>(int id) where T : BaseCsv { Type type = typeof(T); if (!_cnfMap.ContainsKey(type)) { return(null); } Dictionary <int, T> tmpMap = _cnfMap[type] as Dictionary <int, T>; if (tmpMap == null) { LogManager.Error(type.Name + "表结构有问题"); return(null); } if (!tmpMap.ContainsKey(id)) { LogManager.Error(type.Name + "表中未找到Id为:" + id + "的行!"); return(null); } return(tmpMap[id]); }
public static I_TargetSelector Create(TextNode node) { string type_name = node.Name; Type type; _target_select_map.TryGetValue(type_name, out type); if (type == null) { LogManager.Error("找不到对应的类型", type_name); return(null); } I_TargetSelector target_select = Activator.CreateInstance(type) as I_TargetSelector; if (target_select != null) { target_select.Init(node); } else { LogManager.Log("找不到对应的效果[{0}]", type); } return(target_select); }
/// <summary> /// 遍历当前目录及子目录,获取所有文件 /// </summary> /// <param name="strPath">文件路径</param> /// <returns>所有文件</returns> public static List <FileInfo> GetAllFiles(string strPath) { List <FileInfo> lstFiles = new List <FileInfo>(); List <string> lstDirect = new List <string>(); lstDirect.Add(strPath); GetAllDirectorys(strPath, ref lstDirect); var max = lstDirect.Count; for (int idx = 0; idx < max; idx++) { try { DirectoryInfo diFliles = new DirectoryInfo(lstDirect[idx]); lstFiles.AddRange(diFliles.GetFiles()); } catch { LogManager.Error("[GetAllFiles] Error"); } } return(lstFiles); }
private void InitView() { _canChangeItem = true; int count = _listEnhanceItems.Count; if (count <= 0) { return; } _dFactor = (Mathf.RoundToInt((1f / count) * 10000f)) * 0.0001f; _mCenterIndex = count / 2; if (count % 2 == 0) { _mCenterIndex = count / 2 - 1; } int index = 0; for (int i = count - 1; i >= 0; i--) { _listEnhanceItems[i].CurveOffSetIndex = i; if (count != 2) { _listEnhanceItems[i].CenterOffSet = _dFactor * (_mCenterIndex - index); } else//只有2个item时,初始化时第二个item会显示在左边,是因为AnimationCurve的取值区间是[0,1],导致偏移量为1时取值0,[0,1)不知道怎么实现╮(╯▽╰)╭ { //当前的曲线的走向看噩梦关卡/日常活动里的PositionCurve,改成其他曲线时这里可能有坑... _listEnhanceItems[1].CenterOffSet = 0.49f; _listEnhanceItems[0].CenterOffSet = 0.01f; } _listEnhanceItems[i].SetSelectState(false); GameObject obj = _listEnhanceItems[i].gameObject; UDragEnhanceView script = obj.GetComponent <UDragEnhanceView>() ?? obj.AddComponent <UDragEnhanceView>(); if (script != null) { script.SetScrollView(this); } index++; } // set the center item with startCenterIndex if (_startCenterIndex < 0 || _startCenterIndex >= count) { LogManager.Error("## startCenterIndex < 0 || startCenterIndex >= listEnhanceItems.Count out of index ##"); _startCenterIndex = _mCenterIndex; } // sorted items _listSortedItems = new List <EnhanceItem>(_listEnhanceItems.ToArray()); _totalHorizontalWidth = _cellWidth * count; _curCenterItem = _listEnhanceItems[_startCenterIndex]; _curHorizontalValue = 0.5f - _curCenterItem.CenterOffSet; LerpTweenToTarget(0f, _curHorizontalValue, false); if (IsVertical) { _rectTrans.anchoredPosition = new Vector2(0, -_totalHorizontalWidth / 2); _rectTrans.localRotation = Quaternion.Euler(new Vector3(0, 0, 90)); } else { _rectTrans.anchoredPosition = new Vector2(-_totalHorizontalWidth / 2, 0); _rectTrans.localRotation = Quaternion.Euler(new Vector3(0, 0, 0)); } }
/// <summary> /// /// </summary> /// <param name="ar"></param> public void EndReceivePacket(IAsyncResult ar) { int bytes_read = -1; try { if (IsConncted) { lock (_socket) { bytes_read = _socket.EndReceive(ar); } } if (bytes_read == -1) { CloseConnection(); return; } } catch (ObjectDisposedException) { NetLog.Error("Receive Closed"); } catch (Exception ex) { NetLog.Error("{0}\n{1}\n{2}", ex.Message, ex.StackTrace, ex.Source); } NetLog.Assert(bytes_read < NetworkConst.MAX_BUFF_SIZE, "接收到的包太长了"); // Begin Read // int position = 0; // MsgID : 4 | PacketLength : 4 |PACKET : dynamic while (position < bytes_read) { int buffer_size = NetworkHelper.ReadBufferSize(_receive_buffer, ref position /*position + HEAD_SIZE * 0*/); int msg_id = NetworkHelper.ReadMsgId(_receive_buffer, ref position); int msg_data_size = NetworkHelper.ReadPbLength(_receive_buffer, ref position); // TODO 确认心跳线程 // KEEP_ALIVE_SYNC // 保证整个Buffer长度 if (position + msg_data_size > bytes_read) { LogManager.Error("Error receive packet, packet is too long : " + buffer_size); break; } // 接包; IExtensible rsp_packet = UnPackTool.UnPack1(ref position, msg_data_size, _receive_buffer, msg_id); if (rsp_packet == null) { continue; } // 确认某一个消息已经Req_Finish RaiseMessage(); // position += msg_data_size; } Array.Clear(_receive_buffer, 0, _socket.ReceiveBufferSize); BeginReceivePacket(); }
// TODO BUG 这里不能直接引用TextCsv.Loc public static string Loc(this string str) { LogManager.Error("当前不提供这样的功能"); return string.Empty; //return TextCsv.Loc(str); }
// BUG 2018.10.22 针对Buff之间的关系,抽象出一个接口, // 提供给外部 caster(释放buff者)给自身owner添加Buff 处理buff之间的相互关系 重叠/替换/抵消 public void AttachBuff(BaseEntity caster, int buffId) { BuffLog.Assert(!_owner.AttributeProp.IsDead(), "目标[{0}]已经死亡,无法添加Buff:[{1}]", _owner.ToDes(), buffId); if (_owner.AttributeProp.IsDead()) { return; } // 1.根据Id查找对应的ID BuffCnf newCnf = BuffHelper.FindBuffById(buffId); BuffLog.Log("Attach Buff [{0}]", newCnf.desc); // 2.检测buff之间的 关系 int count = 0; int length = _buffList.Count; for (int i = length - 1; i >= 0; i--) { BaseBuff oldBuff = _buffList[i]; if (!oldBuff.Info.CheckGroupById(newCnf.groupID)) { continue; } count++; // TODO BUG逻辑有一定的问题,如果注释掉下面一行代码 //if (count != 1) continue; int newLv = newCnf.level; // 1/0/-1 1=本buff等级更高,0=等级相等,-1=本buff等级会第一点 BuffInfo oldInfo = oldBuff.Info; int lvInfo = oldInfo.CheckLevel(newLv); if (lvInfo == BuffInfo.LESS) // 新buff等级低 { BuffLog.Log("新buff等级低 不处理,新Buff:[{0}],levell:[{1}],老Buff[{2}],level:[{3}]", newCnf.desc, newCnf.level, oldInfo.ToDes(), oldInfo.Level); continue; } if (lvInfo == BuffInfo.EQUAL && oldInfo.Multilayer) // 等级相等,可层级叠加 { BuffLog.Log("Buff:[{0}],等级相等,可层级叠加", oldInfo.ToDes()); _internal_buff_overlap(oldBuff, newCnf); } else if (lvInfo == BuffInfo.EQUAL && !oldInfo.Multilayer) // 等级相等,不可叠加 { BuffLog.Log("Buff:[{0}],等级相等,不可叠加", oldInfo.ToDes()); _internal_buff_refresh_time(oldBuff); } else // 新buff等级高 { BuffLog.Log("Buff:[{0}],新Buff等级高,覆盖", oldInfo.ToDes()); _internal_buff_overlay(caster, _buffList[i], newCnf); } _update_attr(0); //让在update中发挥作用的buff马上生效 } if (count == 0) { _internal_add_new_buff(caster, newCnf); } else if (count > 1) { LogManager.Error("Buff Group Id 超过1个数量"); } }