Exemplo n.º 1
0
    public static AnimData Blink(GameObject animObject, float space,

                                 float time             = 0.5f,
                                 float delayTime        = 0,
                                 bool IsIgnoreTimeScale = false,
                                 RepeatType repeatType  = RepeatType.Once,
                                 int repeatCount        = -1,
                                 AnimCallBack callBack  = null,
                                 object[] parameter     = null)
    {
        AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();;

        l_tmp.m_animType       = AnimType.Blink;
        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_space          = space;

        l_tmp.m_delayTime       = delayTime;
        l_tmp.m_totalTime       = time;
        l_tmp.m_repeatType      = repeatType;
        l_tmp.m_repeatCount     = repeatCount;
        l_tmp.m_callBack        = callBack;
        l_tmp.m_parameter       = parameter;
        l_tmp.m_ignoreTimeScale = IsIgnoreTimeScale;

        l_tmp.Init();

        GetInstance().animList.Add(l_tmp);
        return(l_tmp);
    }
    public override void SendMessage(string MessageType, Dictionary <string, object> data)
    {
        ByteArray msg = HeapObjectPool <ByteArray> .GetObject();

        //ByteArray msg = new ByteArray()
        msg.clear();

        List <byte> message = GetSendByte(MessageType, data);

        int len    = 3 + message.Count;
        int method = GetMethodIndex(MessageType);

        msg.WriteShort(len);
        msg.WriteByte((byte)(method / 100));
        msg.WriteShort(method);

        if (message != null)
        {
            msg.bytes.AddRange(message);
        }
        else
        {
            msg.WriteInt(0);
        }

        Send(msg.Buffer);
        HeapObjectPool <ByteArray> .PutObject(msg);
    }
Exemplo n.º 3
0
    public static AnimData Scale(GameObject animObject, Vector3?from, Vector3 to,
                                 float time             = 0.5f,
                                 InterpType interp      = InterpType.Default,
                                 bool IsIgnoreTimeScale = false,
                                 RepeatType repeatType  = RepeatType.Once,
                                 int repeatCount        = -1,
                                 float delayTime        = 0,
                                 AnimCallBack callBack  = null, object[] parameter = null)
    {
        Vector3 fromTmp = from ?? animObject.transform.localScale;

        AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();;

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = AnimType.LocalScale;
        l_tmp.m_fromV3         = fromTmp;
        l_tmp.m_toV3           = to;

        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);
    }
Exemplo n.º 4
0
    public static AnimData UguiSizeDelta(GameObject animObject, Vector2?from, Vector2 to,

                                         float time             = 0.5f,
                                         float delayTime        = 0,
                                         InterpType interp      = InterpType.Default,
                                         bool IsIgnoreTimeScale = false,
                                         RepeatType repeatType  = RepeatType.Once,
                                         int repeatCount        = -1,
                                         AnimCallBack callBack  = null,
                                         object[] parameter     = null)
    {
        Vector2 fromTmp = from ?? animObject.GetComponent <RectTransform>().sizeDelta;

        AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();;

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = AnimType.UGUI_SizeDetal;
        l_tmp.m_fromV2         = fromTmp;
        l_tmp.m_toV2           = to;

        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);
    }
Exemplo n.º 5
0
    // Update is called once per frame
    public void Update()
    {
        for (int i = 0; i < animList.Count; i++)
        {
            //执行Update
            animList[i].executeUpdate();

            if (animList[i].m_isDone == true)
            {
                AnimData animTmp = animList[i];

                //执行回调
                animTmp.ExecuteCallBack();

                if (!animTmp.AnimReplayLogic())
                {
                    removeList.Add(animTmp);
                }
            }
        }

        for (int i = 0; i < removeList.Count; i++)
        {
            animList.Remove(removeList[i]);
            //释放
            HeapObjectPool <AnimData> .PutObject(removeList[i]);
        }

        removeList.Clear();
    }
Exemplo n.º 6
0
    public static AnimData CustomMethodToVector3(AnimCustomMethodVector3 method, Vector3 from, Vector3 to,
                                                 float time             = 0.5f,
                                                 float delayTime        = 0,
                                                 InterpType interp      = InterpType.Default,
                                                 bool IsIgnoreTimeScale = false,
                                                 RepeatType repeatType  = RepeatType.Once,
                                                 int repeatCount        = -1,
                                                 AnimCallBack callBack  = null, object[] parameter = null)
    {
        AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();;

        l_tmp.m_animType       = AnimType.Custom_Vector3;
        l_tmp.m_fromV3         = from;
        l_tmp.m_toV2           = to;
        l_tmp.m_customMethodV3 = method;

        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);
    }
Exemplo n.º 7
0
    static void Update()
    {
        m_traversalList.Clear();
        m_traversalList.AddRange(m_timers);

        for (int i = 0; i < m_traversalList.Count; i++)
        {
            m_traversalList[i].Update();

            if (m_traversalList[i].m_isDone)
            {
                TimerEvent e = m_traversalList[i];

                e.CompleteTimer();

                if (e.m_repeatCount == 0)
                {
                    m_removeList.Add(e);
                }
            }
        }

        for (int i = 0; i < m_removeList.Count; i++)
        {
            m_timers.Remove(m_removeList[i]);
            HeapObjectPool <TimerEvent> .PutObject(m_removeList[i]);
        }
    }
Exemplo n.º 8
0
    public List <ECSGroup> GetEntitySuportGroup(EntityBase entity)
    {
#if !Server
        List <ECSGroup> groupNames = HeapObjectPool <List <ECSGroup> > .GetObject();

        groupNames.Clear();
#else
        List <ECSGroup> groupNames = new List <ECSGroup>();
#endif

        for (int i = 0; i < allGroupList.Count; i++)
        {
            ECSGroup group      = allGroupList[i];
            int[]    filterCom  = group.ComponentHashs;
            bool     isContains = true;
            for (int j = 0; j < filterCom.Length; j++)
            {
                if (!entity.GetExistComp(filterCom[j]))
                {
                    isContains = false;
                    break;
                }
            }
            if (isContains)
            {
                groupNames.Add(group);
            }
        }

        return(groupNames);
    }
    public void EditorTest()
    {
        //取出两个
        HeapTest a = HeapObjectPool <HeapTest> .GetObject();

        HeapTest b = HeapObjectPool <HeapTest> .GetObject();

        Assert.AreEqual(a.isFetch, true);
        Assert.AreEqual(b.isFetch, true);

        //放回一个
        HeapObjectPool <HeapTest> .PutObject(a);

        Assert.AreEqual(a.isFetch, false);

        //取出三个
        HeapTest c = HeapObjectPool <HeapTest> .GetObject();

        HeapTest d = HeapObjectPool <HeapTest> .GetObject();

        HeapTest e = HeapObjectPool <HeapTest> .GetObject();

        Assert.AreEqual(a, c);

        Assert.AreEqual(c.isFetch, true);
        Assert.AreEqual(d.isFetch, true);
        Assert.AreEqual(e.isFetch, true);
    }
Exemplo n.º 10
0
    public static AnimData AlphaTo(GameObject animObject, float from, float to,

                                   float time             = 0.5f,
                                   float delayTime        = 0,
                                   InterpType interp      = InterpType.Default,
                                   bool IsIgnoreTimeScale = false,
                                   RepeatType repeatType  = RepeatType.Once,
                                   int repeatCount        = -1,
                                   bool isChild           = true,
                                   AnimCallBack callBack  = null, object[] parameter = null)
    {
        AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();;

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = AnimType.Alpha;
        l_tmp.m_fromFloat      = from;
        l_tmp.m_toFloat        = 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);
    }
Exemplo n.º 11
0
    // Update is called once per frame
    public void Update()
    {
        for (int i = 0; i < animList.Count; i++)
        {
            //执行Update
            animList[i].executeUpdate();

            if (animList[i].m_isDone == true)
            {
                AnimData animTmp = animList[i];

                if (!animTmp.AnimReplayLogic())
                {
                    animList.Remove(animTmp);
                    i--;

                    //释放
                    //animTmp.Release();
                    HeapObjectPool <AnimData> .PutObject(animTmp);
                }

                //执行回调
                animTmp.executeCallBack();
            }
        }
    }
Exemplo n.º 12
0
    public override MomentSingletonComponent DeepCopy()
    {
        TestSingleComponent tc = HeapObjectPool <TestSingleComponent> .GetObject();// new TestSingleComponent();

        tc.testValue = testValue;

        return(tc);
    }
Exemplo n.º 13
0
    //public static T GetEvent<T>() where T : IInputEventBase, new()
    //{
    //    return InputOperationEventProxy.GetEvent<T>();
    //}

    public static T GetEvent <T>(string eventKey) where T : IInputEventBase, new()
    {
        T tmp = HeapObjectPool <T> .GetObject();

        tmp.EventKey = eventKey;

        return(tmp);
    }
Exemplo n.º 14
0
    /// <summary>
    /// 立即完成一个动画
    /// </summary>
    /// <param name="animGameObject">要完成的</param>
    public static void FinishAnim(AnimData animData)
    {
        animData.m_currentTime = animData.m_totalTime;
        animData.executeUpdate();
        animData.ExecuteCallBack();

        GetInstance().animList.Remove(animData);
        HeapObjectPool <AnimData> .PutObject(animData);
    }
    public static void OnEveryEventCallBack(string eventName, IInputEventBase inputEvent)
    {
        Dictionary <string, object> tmp = HeapObjectPool.GetSODict();

        tmp.Add(c_eventNameKey, inputEvent.GetType().Name);
        tmp.Add(c_serializeInfoKey, inputEvent.Serialize());

        WriteInputEvent(Json.Serialize(tmp));
    }
Exemplo n.º 16
0
    /// <summary>
    /// 停止一个动画
    /// </summary>
    /// <param name="animGameObject">要停止的动画</param>
    /// <param name="isCallBack">是否触发回调</param>
    public static void StopAnim(AnimData animData, bool isCallBack = false)
    {
        if (isCallBack)
        {
            animData.ExecuteCallBack();
        }

        GetInstance().animList.Remove(animData);
        HeapObjectPool <AnimData> .PutObject(animData);
    }
    static T GetUIEvent <T>(string UIName, string ComponentName, string parm) where T : InputUIEventBase, new()
    {
        T msg = HeapObjectPool <T> .GetObject();

        msg.Reset();
        msg.m_name     = UIName;
        msg.m_compName = ComponentName;
        msg.m_pram     = parm;

        return(msg);
    }
    public static InputEventRegisterInfo <InputUIOnEndDragEvent> AddOnEndDragListener(string UIName, string ComponentName, InputEventHandle <InputUIOnEndDragEvent> callback)
    {
        InputEventRegisterInfo <InputUIOnEndDragEvent> info = HeapObjectPool <InputEventRegisterInfo <InputUIOnEndDragEvent> > .GetObject();

        info.eventKey = InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName);
        info.callBack = callback;

        InputManager.AddListener <InputUIOnEndDragEvent>(
            InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName), callback);

        return(info);
    }
Exemplo n.º 19
0
    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);
    }
Exemplo n.º 20
0
 public void Release()
 {
     try
     {
         OnRelease();
     }
     catch (Exception e)
     {
         Debug.LogError(e.ToString());
     }
     HeapObjectPool.ReleaseObject(GetType().Name, this);
 }
Exemplo n.º 21
0
    public static void DestroyAllTimer(bool isCallBack = false)
    {
        for (int i = 0; i < m_timers.Count; i++)
        {
            if (isCallBack)
            {
                m_timers[i].CallBackTimer();
            }
            HeapObjectPool <TimerEvent> .PutObject(m_timers[i]);
        }

        m_timers.Clear();
    }
Exemplo n.º 22
0
    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);
    }
Exemplo n.º 23
0
    public static void ClearAllAnim(bool isCallBack = false)
    {
        for (int i = 0; i < GetInstance().animList.Count; i++)
        {
            AnimData animTmp = GetInstance().animList[i];
            if (isCallBack)
            {
                animTmp.ExecuteCallBack();
            }
            HeapObjectPool <AnimData> .PutObject(animTmp);
        }

        GetInstance().animList.Clear();
    }
Exemplo n.º 24
0
    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);
    }
Exemplo n.º 25
0
 static int GetObjList(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         System.Collections.Generic.List <object> o = HeapObjectPool.GetObjList();
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 26
0
    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);
    }
Exemplo n.º 27
0
    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.GetObject <AnimData>("AnimData");

        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);
    }
Exemplo n.º 28
0
    public void OnEntityDestroy(EntityBase entity)
    {
        List <ECSGroup> list = entityToGroupDic[entity];

        for (int i = 0; i < list.Count; i++)
        {
            groupToEntityDic[list[i]].Remove(entity);
        }

        entityToGroupDic.Remove(entity);
        list.Clear();
#if !Server
        HeapObjectPool <List <ECSGroup> > .PutObject(list);
#endif
    }
Exemplo n.º 29
0
    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);
    }
Exemplo n.º 30
0
    public static void DestroyTimer(TimerEvent timer, bool isCallBack = false)
    {
        if (m_timers.Contains(timer))
        {
            if (isCallBack)
            {
                timer.CallBackTimer();
            }

            m_timers.Remove(timer);
            HeapObjectPool <TimerEvent> .PutObject(timer);
        }
        else
        {
            Debug.LogError("Timer DestroyTimer error: dont exist timer " + timer);
        }
    }