// 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();
    }
    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);
    }
示例#3
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]);
        }
    }
示例#4
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();
            }
        }
    }
    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);
    }
    /// <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);
    }
    /// <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);
    }
示例#8
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();
    }
    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();
    }
示例#10
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
    }
示例#11
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);
        }
    }
    //解包
    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());
        }
    }
示例#13
0
    static void Update()
    {
        for (int i = 0; i < m_timers.Count; i++)
        {
            m_timers[i].Update();

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

                e.CompleteTimer();

                if (e.m_repeatCount == 0)
                {
                    m_timers.Remove(e);
                    HeapObjectPool <TimerEvent> .PutObject(e);

                    i--;
                }
            }
        }
    }
    /// <summary>
    /// 停止一个对象身上的所有动画
    /// </summary>
    /// <param name="animGameObject">要停止动画的对象</param>
    /// <param name="isCallBack">是否触发回调</param>
    public static void StopAnim(GameObject animGameObject, bool isCallBack = false)
    {
        for (int i = 0; i < GetInstance().animList.Count; i++)
        {
            if (GetInstance().animList[i].m_animGameObejct == animGameObject)
            {
                AnimData animData = GetInstance().animList[i];

                if (isCallBack)
                {
                    animData.ExecuteCallBack();
                }

                GetInstance().removeList.Add(animData);
            }
        }

        for (int i = 0; i < GetInstance().removeList.Count; i++)
        {
            GetInstance().animList.Remove(GetInstance().removeList[i]);
            HeapObjectPool <AnimData> .PutObject(GetInstance().removeList[i]);
        }
    }
 public virtual void RemoveListener()
 {
     InputManager.RemoveListener <T>(eventKey, callBack);
     HeapObjectPool <InputEventRegisterInfo <T> > .PutObject(this);
 }
    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());
        }
    }
 public static void PutSODict(Dictionary <string, object> dict)
 {
     dict.Clear();
     HeapObjectPool <Dictionary <string, object> > .PutObject(dict);
 }