public static InputEventRegisterInfo <InputUIOnEndDragEvent> AddOnEndDragListener(string UIName, string ComponentName, InputEventHandle <InputUIOnEndDragEvent> callback) { InputEventRegisterInfo <InputUIOnEndDragEvent> info = HeapObjectPool.GetObject <InputEventRegisterInfo <InputUIOnEndDragEvent> >(); info.eventKey = InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName); info.callBack = callback; InputManager.AddListener <InputUIOnEndDragEvent>( InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName), callback); return(info); }
public static InputEventRegisterInfo <InputUIOnScrollEvent> GetOnScrollListener(string UIName, string ComponentName, InputEventHandle <InputUIOnScrollEvent> callback) { InputEventRegisterInfo <InputUIOnScrollEvent> info = HeapObjectPool <InputEventRegisterInfo <InputUIOnScrollEvent> > .GetObject(); info.eventKey = InputUIOnScrollEvent.GetEventKey(UIName, ComponentName); info.callBack = callback; InputManager.AddListener( InputUIOnScrollEvent.GetEventKey(UIName, ComponentName), callback); return(info); }
internal static InputEventRegisterInfo <InputUIOnMouseEvent> GetOnMouseListener(string m_UIEventKey, string UIName, string ComponentName, bool isDown, InputEventHandle <InputUIOnMouseEvent> callback) { InputEventRegisterInfo <InputUIOnMouseEvent> info = HeapObjectPool <InputEventRegisterInfo <InputUIOnMouseEvent> > .GetObject(); info.eventKey = InputUIOnMouseEvent.GetEventKey(UIName, ComponentName, isDown); info.callBack = callback; InputManager.AddListener( InputUIOnMouseEvent.GetEventKey(UIName, ComponentName, isDown), callback); return(info); }
public static InputButtonClickRegisterInfo GetOnClickListener(Button button, string UIName, string ComponentName, string parm, InputEventHandle <InputUIOnClickEvent> callback) { InputButtonClickRegisterInfo info = HeapObjectPool <InputButtonClickRegisterInfo> .GetObject(); info.eventKey = InputUIOnClickEvent.GetEventKey(UIName, ComponentName, parm); info.callBack = callback; info.m_button = button; info.m_OnClick = () => { DispatchOnClickEvent(UIName, ComponentName, parm); }; return(info); }
public static InputEndDragRegisterInfo GetOnEndDragListener(DragAcceptor acceptor, string UIName, string ComponentName, string parm, InputEventHandle <InputUIOnEndDragEvent> callback) { InputEndDragRegisterInfo info = HeapObjectPool <InputEndDragRegisterInfo> .GetObject(); info.eventKey = InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName); info.callBack = callback; info.m_acceptor = acceptor; info.m_OnEndDrag = (data) => { DispatchEndDragEvent(UIName, ComponentName, parm, data); }; return(info); }
public static InputEventRegisterInfo <InputUILongPressEvent> GetLongPressListener(LongPressAcceptor acceptor, string UIName, string ComponentName, string parm, InputEventHandle <InputUILongPressEvent> callback) { InputlongPressRegisterInfo info = HeapObjectPool <InputlongPressRegisterInfo> .GetObject(); info.eventKey = InputUILongPressEvent.GetEventKey(UIName, ComponentName, parm); info.callBack = callback; info.m_acceptor = acceptor; info.m_OnLongPress = (type) => { DispatchLongPressEvent(UIName, ComponentName, parm, type); }; return(info); }
public static AnimData Rotate(GameObject animObject, Vector3?from, Vector3 to, float time = 0.5f, float delayTime = 0, bool isLocal = true, InterpType interp = InterpType.Default, bool IsIgnoreTimeScale = false, RepeatType repeatType = RepeatType.Once, int repeatCount = -1, AnimCallBack callBack = null, object[] parameter = null) { AnimType animType; Vector3 fromTmp; if (isLocal) { fromTmp = from ?? animObject.transform.localEulerAngles; animType = AnimType.LocalRotate; } else { fromTmp = from ?? animObject.transform.eulerAngles; animType = AnimType.Rotate; } AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();; l_tmp.m_animGameObejct = animObject; l_tmp.m_animType = animType; l_tmp.m_fromV3 = fromTmp; l_tmp.m_toV3 = to; l_tmp.m_isLocal = isLocal; l_tmp.m_delayTime = delayTime; l_tmp.m_totalTime = time; l_tmp.m_interpolationType = interp; l_tmp.m_repeatType = repeatType; l_tmp.m_repeatCount = repeatCount; l_tmp.m_ignoreTimeScale = IsIgnoreTimeScale; l_tmp.m_callBack = callBack; l_tmp.m_parameter = parameter; l_tmp.Init(); GetInstance().animList.Add(l_tmp); return(l_tmp); }
public static AnimData BezierMove(GameObject animObject, Vector3?from, Vector3 to, Vector3[] bezier_contral, float time = 0.5f, float delayTime = 0, RepeatType repeatType = RepeatType.Once, int repeatCount = -1, InterpType interp = InterpType.Default, bool isLocal = true, PathType bezierMoveType = PathType.Bezier2, AnimCallBack callBack = null, object[] parameter = null) { AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();; if (isLocal) { l_tmp.m_animType = AnimType.LocalPosition; l_tmp.m_fromV3 = from ?? animObject.transform.localPosition; } else { l_tmp.m_animType = AnimType.Position; l_tmp.m_fromV3 = from ?? animObject.transform.position; } l_tmp.m_animGameObejct = animObject; l_tmp.m_toV3 = to; l_tmp.m_isLocal = isLocal; l_tmp.m_pathType = bezierMoveType; l_tmp.m_v3Contral = bezier_contral; l_tmp.m_delayTime = delayTime; l_tmp.m_totalTime = time; l_tmp.m_interpolationType = interp; l_tmp.m_repeatType = repeatType; l_tmp.m_repeatCount = repeatCount; l_tmp.m_callBack = callBack; l_tmp.m_parameter = parameter; l_tmp.Init(); GetInstance().animList.Add(l_tmp); return(l_tmp); }
/// <summary> /// 添加一个Timer /// </summary> /// <param name="spaceTime">间隔时间</param> /// <param name="isIgnoreTimeScale">是否忽略时间缩放</param> /// <param name="callBackCount">重复调用的次数</param> /// <param name="timerName">Timer的名字</param> /// <param name="callBack">回调函数</param> /// <param name="objs">回调函数的参数</param> /// <returns></returns> public static TimerEvent AddTimer(float spaceTime, bool isIgnoreTimeScale, int callBackCount, string timerName, TimerCallBack callBack, params object[] objs) { TimerEvent te = HeapObjectPool <TimerEvent> .GetObject(); te.m_timerName = timerName; te.m_currentTimer = 0; te.m_timerSpace = spaceTime; te.m_callBack = callBack; te.m_objs = objs; te.m_isIgnoreTimeScale = isIgnoreTimeScale; te.m_repeatCount = callBackCount; m_timers.Add(te); return(te); }
/// <summary> /// 动画过度到目标颜色 /// </summary> /// <param name="animObject">动画对象</param> /// <param name="from">起始颜色(可空)</param> /// <param name="to">目标颜色</param> /// <param name="time">动画时间</param> /// <param name="isChild">是否影响子节点</param> /// <param name="interp">插值类型</param> /// <param name="IsIgnoreTimeScale">是否忽略时间缩放</param> /// <param name="repeatType">重复类型</param> /// <param name="repeatCount">重复次数</param> /// <param name="callBack">动画完成回调函数</param> /// <param name="parameter">动画完成回调函数传参</param> /// <returns></returns> public static AnimData UguiColor(GameObject animObject, Color?from, Color to, float time = 0.5f, float delayTime = 0, InterpType interp = InterpType.Default, bool isChild = true, bool IsIgnoreTimeScale = false, RepeatType repeatType = RepeatType.Once, int repeatCount = -1, AnimCallBack callBack = null, object[] parameter = null) { Color fromTmp = from ?? Color.white; if (from == null) { if (animObject.GetComponent <Graphic>() != null) { fromTmp = from ?? animObject.GetComponent <Graphic>().color; } } AnimData l_tmp = HeapObjectPool <AnimData> .GetObject(); l_tmp.m_animGameObejct = animObject; l_tmp.m_animType = AnimType.UGUI_Color; l_tmp.m_fromColor = fromTmp; l_tmp.m_toColor = to; l_tmp.m_isChild = isChild; l_tmp.m_delayTime = delayTime; l_tmp.m_totalTime = time; l_tmp.m_interpolationType = interp; l_tmp.m_repeatType = repeatType; l_tmp.m_repeatCount = repeatCount; l_tmp.m_ignoreTimeScale = IsIgnoreTimeScale; l_tmp.m_callBack = callBack; l_tmp.m_parameter = parameter; l_tmp.Init(); GetInstance().animList.Add(l_tmp); return(l_tmp); }
//解包 private void ReceiveDataLoad(byte[] bytes) { try { ByteArray ba = HeapObjectPool <ByteArray> .GetObject(); //用于做数据处理,加解密,或者压缩于解压缩 ba.clear(); ba.Add(bytes); NetWorkMessage msg = Analysis(ba); m_messageCallBack(msg); HeapObjectPool <ByteArray> .PutObject(ba); } catch (Exception e) { Debug.LogError(e.ToString()); } }
private List <byte> GetCustomTypeByte(string customType, Dictionary <string, object> data) { string fieldName = null; int fieldType = 0; int repeatType = 0; try { ByteArray Bytes = HeapObjectPool <ByteArray> .GetObject(); //ByteArray Bytes = new ByteArray(); Bytes.clear(); if (!m_protocolInfo.ContainsKey(customType)) { throw new Exception("ProtocolInfo NOT Exist ->" + customType + "<-"); } List <Dictionary <string, object> > tableInfo = m_protocolInfo[customType]; for (int i = 0; i < tableInfo.Count; i++) { Dictionary <string, object> currentField = tableInfo[i]; fieldType = (int)currentField["type"]; fieldName = (string)currentField["name"]; repeatType = (int)currentField["spl"]; if (fieldType == TYPE_string) { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { Bytes.WriteString((string)data[fieldName]); } else { List <object> list = (List <object>)data[fieldName]; Bytes.WriteShort(list.Count); Bytes.WriteInt(GetStringListLength(list)); for (int i2 = 0; i2 < list.Count; i2++) { Bytes.WriteString((string)list[i2]); } } } else { Bytes.WriteShort(0); } } else if (fieldType == TYPE_bool) { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { Bytes.WriteBoolean((bool)data[fieldName]); } else { List <object> tb = (List <object>)data[fieldName]; Bytes.WriteShort(tb.Count); Bytes.WriteInt(tb.Count); for (int i2 = 0; i2 < tb.Count; i2++) { Bytes.WriteBoolean((bool)tb[i2]); } } } } else if (fieldType == TYPE_double) { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { Bytes.WriteDouble((float)data[fieldName]); } else { List <object> tb = (List <object>)data[fieldName]; Bytes.WriteShort(tb.Count); Bytes.WriteInt(tb.Count * 8); for (int j = 0; j < tb.Count; j++) { Bytes.WriteDouble((float)tb[j]); } } } } else if (fieldType == TYPE_int32) { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { Bytes.WriteInt(int.Parse(data[fieldName].ToString())); } else { List <object> tb = (List <object>)data[fieldName]; Bytes.WriteShort(tb.Count); Bytes.WriteInt(tb.Count * 4); for (int i2 = 0; i2 < tb.Count; i2++) { Bytes.WriteInt(int.Parse(tb[i2].ToString())); } } } } else if (fieldType == TYPE_int16) { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { Bytes.WriteShort(int.Parse(data[fieldName].ToString())); } else { List <object> tb = (List <object>)data[fieldName]; Bytes.WriteShort(tb.Count); Bytes.WriteInt(tb.Count * 2); for (int i2 = 0; i2 < tb.Count; i2++) { Bytes.WriteShort(int.Parse(tb[i2].ToString())); } } } } else if (fieldType == TYPE_int8) { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { Bytes.WriteInt8(int.Parse(data[fieldName].ToString())); } else { List <object> tb = (List <object>)data[fieldName]; Bytes.WriteShort(tb.Count); Bytes.WriteInt(tb.Count); for (int i2 = 0; i2 < tb.Count; i2++) { Bytes.WriteInt8(int.Parse(tb[i2].ToString())); } } } } else { if (data.ContainsKey(fieldName)) { if (repeatType == RT_equired) { customType = (string)currentField["vp"]; Bytes.bytes.AddRange(GetSendByte(customType, (Dictionary <string, object>)data[fieldName])); } else { List <object> tb = (List <object>)data[fieldName]; Bytes.WriteShort(tb.Count); //这里会修改m_arrayCatch的值,下面就可以直接使用 Bytes.WriteInt(GetCustomListLength(customType, tb)); for (int j = 0; j < m_arrayCatch.Count; j++) { List <byte> tempb = m_arrayCatch[j]; Bytes.WriteInt(tempb.Count); Bytes.bytes.AddRange(tempb); } } } } } HeapObjectPool <ByteArray> .PutObject(Bytes); return(Bytes.bytes); } catch (Exception e) { throw new Exception(@"GetCustomTypeByte Excepiton CustomType is ->" + customType + "<-\nFieldName:->" + fieldName + "<-\nFieldType:->" + GetFieldType(fieldType) + "<-\nRepeatType:->" + GetRepeatType(repeatType) + "<-\nCustomType:->" + customType + "<-\n" + e.ToString()); } }
Dictionary <string, object> AnalysisData(string MessageType, byte[] bytes) { //Debug.Log("MessageType:" + MessageType + "AnalysisData: " + BitConverter.ToString(bytes)); string fieldName = ""; string customType = ""; int fieldType = 0; int repeatType = 0; try { Dictionary <string, object> data = new Dictionary <string, object>(); ByteArray ba = HeapObjectPool <ByteArray> .GetObject(); ba.clear(); ba.Add(bytes); string messageTypeTemp = "m_" + MessageType + "_c"; if (!m_protocolInfo.ContainsKey(messageTypeTemp)) { throw new Exception("ProtocolInfo NOT Exist ->" + messageTypeTemp + "<-"); } List <Dictionary <string, object> > tableInfo = m_protocolInfo["m_" + MessageType + "_c"]; for (int i = 0; i < tableInfo.Count; i++) { fieldType = (int)tableInfo[i]["type"]; repeatType = (int)tableInfo[i]["spl"]; fieldName = (string)tableInfo[i]["name"]; if (fieldType == TYPE_string) { if (repeatType == RT_repeated) { data[fieldName] = ReadStringList(ba); } else { data[fieldName] = ReadString(ba); } } else if (fieldType == TYPE_bool) { if (repeatType == RT_repeated) { data[fieldName] = ReadBoolList(ba); } else { data[fieldName] = ReadBool(ba); } } else if (fieldType == TYPE_double) { if (repeatType == RT_repeated) { data[fieldName] = ReadDoubleList(ba); } else { data[fieldName] = ReadDouble(ba); } } else if (fieldType == TYPE_int32) { if (repeatType == RT_repeated) { data[fieldName] = ReadIntList(ba); } else { data[fieldName] = ReadInt32(ba); } } else if (fieldType == TYPE_int16) { if (repeatType == RT_repeated) { data[fieldName] = ReadShortList(ba); } else { data[fieldName] = ReadInt16(ba); } } else if (fieldType == TYPE_int8) { if (repeatType == RT_repeated) { data[fieldName] = ReadInt8List(ba); } else { data[fieldName] = ReadInt8(ba); } } else { customType = (string)tableInfo[i]["vp"]; if (repeatType == RT_repeated) { data[fieldName] = ReadDictionaryList(customType, ba); } else { data[fieldName] = ReadDictionary(customType, ba); } } } return(data); } catch (Exception e) { throw new Exception(@"AnalysisData Excepiton Data is ->" + MessageType + "<-\nFieldName:->" + fieldName + "<-\nFieldType:->" + GetFieldType(fieldType) + "<-\nRepeatType:->" + GetRepeatType(repeatType) + "<-\nCustomType:->" + customType + "<-\n" + e.ToString()); } }
public AnimData GetAnimData() { AnimData DataTmp = HeapObjectPool <AnimData> .GetObject(); foreach (var hash in this) { AnimParamType l_ParamType = hash.Key; switch (l_ParamType) { //基础参数 case AnimParamType.GameObj: DataTmp.m_animGameObejct = (GameObject)hash.Value; break; case AnimParamType.AnimType: DataTmp.m_animType = (AnimType)hash.Value; break; case AnimParamType.Time: DataTmp.m_totalTime = (float)hash.Value; break; case AnimParamType.InteType: DataTmp.m_interpolationType = (InterpType)hash.Value; break; case AnimParamType.RepeatType: DataTmp.m_repeatType = (RepeatType)hash.Value; break; case AnimParamType.RepeatCount: DataTmp.m_repeatCount = (int)hash.Value; break; case AnimParamType.DelayTime: DataTmp.m_delayTime = (float)hash.Value; break; //From case AnimParamType.FromV3: DataTmp.m_fromV3 = (Vector3)hash.Value; break; case AnimParamType.FromV2: DataTmp.m_fromV2 = (Vector2)hash.Value; break; case AnimParamType.FromColor: DataTmp.m_fromColor = (Color)hash.Value; break; case AnimParamType.FromFloat: DataTmp.m_fromFloat = (float)hash.Value; break; //To case AnimParamType.ToV3: DataTmp.m_toV3 = (Vector3)hash.Value; break; case AnimParamType.ToV2: DataTmp.m_toV2 = (Vector2)hash.Value; break; case AnimParamType.ToColor: DataTmp.m_toColor = (Color)hash.Value; break; case AnimParamType.ToFloat: DataTmp.m_toFloat = (float)hash.Value; break; //动画回调 case AnimParamType.CallBack: DataTmp.m_callBack = (AnimCallBack)hash.Value; break; case AnimParamType.CallBackParams: DataTmp.m_parameter = (object[])hash.Value; break; //定制函数 case AnimParamType.CustomMethodV3: DataTmp.m_customMethodV3 = (AnimCustomMethodVector3)hash.Value; break; case AnimParamType.CustomMethodV2: DataTmp.m_customMethodV2 = (AnimCustomMethodVector2)hash.Value; break; case AnimParamType.CustomMethodFloat: DataTmp.m_customMethodFloat = (AnimCustomMethodFloat)hash.Value; break; //闪烁 case AnimParamType.Space: DataTmp.m_space = (float)hash.Value; break; //贝塞尔控制点 case AnimParamType.PathType: DataTmp.m_pathType = (PathType)hash.Value; break; case AnimParamType.V3Control: DataTmp.m_v3Contral = (Vector3[])hash.Value; break; case AnimParamType.floatControl: DataTmp.m_floatContral = (float[])hash.Value; break; //其他设置 case AnimParamType.IsIncludeChild: DataTmp.m_isChild = (bool)hash.Value; break; case AnimParamType.IsLocal: DataTmp.m_isLocal = (bool)hash.Value; break; case AnimParamType.IsIgnoreTimeScale: DataTmp.m_ignoreTimeScale = (bool)hash.Value; break; } } return(DataTmp); }
public static Dictionary <string, object> GetSODict() { return(HeapObjectPool <Dictionary <string, object> > .GetObject()); }
//传From,传准确控制点随机范围 public static AnimData BezierMove(GameObject animObject, Vector3?from, Vector3 to, float time, float[] t_Bezier_contralRadius, RepeatType repeatType, int repeatCount = -1, float delayTime = 0, InterpType interp = InterpType.Default, bool isLocal = true, PathType bezierMoveType = PathType.Bezier2, AnimCallBack callBack = null, object[] parameter = null) { AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();; if (isLocal) { l_tmp.m_animType = AnimType.LocalPosition; l_tmp.m_fromV3 = from ?? animObject.transform.localPosition; } else { l_tmp.m_animType = AnimType.Position; l_tmp.m_fromV3 = from ?? animObject.transform.position; } l_tmp.m_animGameObejct = animObject; l_tmp.m_toV3 = to; l_tmp.m_isLocal = isLocal; l_tmp.m_pathType = bezierMoveType; l_tmp.m_floatContral = t_Bezier_contralRadius; l_tmp.m_delayTime = delayTime; l_tmp.m_totalTime = time; l_tmp.m_interpolationType = interp; l_tmp.m_repeatType = repeatType; l_tmp.m_repeatCount = repeatCount; l_tmp.m_callBack = callBack; l_tmp.m_parameter = parameter; l_tmp.Init(); GetInstance().animList.Add(l_tmp); return(l_tmp); //AnimType animType; //if (isLocal) //{ // animType = AnimType.LocalPosition; //} //else //{ // animType = AnimType.Position; //} //AnimParamHash animParnHash = HashTemp.SetData( // AnimParamType.GameObj, animObject, // AnimParamType.AnimType, animType, // AnimParamType.FromV3, from, // AnimParamType.ToV3, to, // AnimParamType.Time, time, // AnimParamType.InteType, interp, // AnimParamType.IsLocal, isLocal, // AnimParamType.PathType, bezierMoveType, // AnimParamType.floatControl, t_Bezier_contralRadius, // AnimParamType.RepeatType, repeatType, // AnimParamType.CallBack, callBack, // AnimParamType.CallBackParams, parameter // ); //return ValueTo(animParnHash); }
protected NetWorkMessage GetMessageByPool() { NetWorkMessage result = HeapObjectPool <NetWorkMessage> .GetObject(); return(result); }