示例#1
0
 public void RemoveAcceptUpdatedObject(ApolloObject obj)
 {
     if (obj != null && acceptUpdatedObjectList.Contains(obj))
     {
         acceptUpdatedObjectList.Remove(obj);
     }
 }
示例#2
0
        static void onSendResultBuffer(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, int result, IntPtr buffer, int len)
        {
            //ADebug.Log("onSendResultBuffer enter:"+function+" "+objectId  + " buffer len:" + len);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();

                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(int), typeof(byte[]) }, null);
                if (method != null)
                {
                    byte[] data = new byte[len];
                    if (buffer != IntPtr.Zero && len > 0)
                    {
                        Marshal.Copy(buffer, data, 0, len);
                    }
                    method.Invoke(obj, new object[] { result, data });
                    //ADebug.Log("onSendResultBuffer success");
                }
                else
                {
                    ADebug.LogError("onSendResultBuffer not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendResultBuffer:" + objectId + " do not exist");
            }
        }
示例#3
0
 public void AddAcceptUpdatedObject(ApolloObject obj)
 {
     if (obj != null && !acceptUpdatedObjectList.Contains(obj))
     {
         acceptUpdatedObjectList.Add(obj);
     }
 }
示例#4
0
        static void onSendStruct(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr param)
        {
            //ADebug.Log("onSendStruct enter:"+function+" "+objectId);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();


                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(IntPtr) }, null);
                if (method != null)
                {
                    method.Invoke(obj, new object[] { param });
                    //ADebug.Log("onSendStruct success");
                }
                else
                {
                    ADebug.LogError("onSendStruct not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendStruct:" + objectId + " do not exist");
            }
        }
示例#5
0
        static void onSendMessage(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPStr)] string param)
        {
            if (!ApolloObjectManager.Instance.dictObjectCollection.ContainsKey(objectId))
            {
                ADebug.LogError("onSendMessage not exist: " + objectId + " function:" + function + " param:" + param);
                return;
            }
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();

                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(string) }, null);
                if (method != null)
                {
                    method.Invoke(obj, new object[] { param });
                    //ADebug.Log("onSendMessage success");
                }
                else
                {
                    ADebug.LogError("onSendMessage not exist method:" + function);
                }
            }
            else
            {
                ADebug.Log("onSendMessage:" + objectId + " do not exist");
            }
        }
示例#6
0
 public void OnApplicationPause(bool pauseStatus)
 {
     ADebug.Log("ObjectManager OnApplicationPause:" + pauseStatus);
     for (int j = 0; j < acceptUpdatedObjectList.Count; j++)
     {
         ApolloObject obj = acceptUpdatedObjectList[j];
         obj.OnApplicationPause(pauseStatus);
     }
 }
示例#7
0
 public void ClearObjects()
 {
     foreach (UInt64 key in dictObjectCollection.Keys)
     {
         ApolloObject obj = dictObjectCollection[key];
         removePlatformObject(obj.ObjectId);
     }
     dictObjectCollection.Clear();
 }
示例#8
0
        public void Update()
        {
            ////////////////////////////////////////////////////////////////////////////////////
            // acceptUpdatedObjectList
            ////////////////////////////////////////////////////////////////////////////////////
            for (int i = 0; i < acceptUpdatedObjectList.Count; i++)
            {
                ApolloObject o = acceptUpdatedObjectList[i];

                if (o.Removable)
                {
                    removedUpdatableList.Add(o);
                }
                else
                {
                    o.Update();
                }
            }

            for (int i = 0; i < removedUpdatableList.Count; i++)
            {
                ApolloObject o = removedUpdatableList[i];
                if (o != null)
                {
                    RemoveAcceptUpdatedObject(o);
                }
            }
            removedUpdatableList.Clear();

            ////////////////////////////////////////////////////////////////////////////////////
            // removedReflectibleList
            ////////////////////////////////////////////////////////////////////////////////////

            Dictionary <UInt64, ApolloObject> .Enumerator enumerator = dictObjectCollection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                KeyValuePair <UInt64, ApolloObject> pair = enumerator.Current;
                ApolloObject o = pair.Value as ApolloObject;

                if (o != null && o.Removable)
                {
                    removedReflectibleList.Add(o);
                }
            }

            for (int i = 0; i < removedReflectibleList.Count; i++)
            {
                ApolloObject o = removedReflectibleList[i];
                if (o != null)
                {
                    RemoveObject(o);
                }
            }
            removedReflectibleList.Clear();
        }
示例#9
0
 public void OnDisable()
 {
     ADebug.Log("ObjectManager OnDisable");
     for (int j = 0; j < acceptUpdatedObjectList.Count; j++)
     {
         ApolloObject obj = acceptUpdatedObjectList[j];
         obj.OnDisable();
     }
     acceptUpdatedObjectList.Clear();
 }
示例#10
0
 public void RemoveObject(ApolloObject obj)
 {
     if (obj == null)
     {
         return;
     }
     if (dictObjectCollection.ContainsKey(obj.ObjectId))
     {
         dictObjectCollection.Remove(obj.ObjectId);
         removePlatformObject(obj.ObjectId);
     }
 }
示例#11
0
        public void OnApplicationQuit()
        {
            ADebug.Log("ObjectManager OnApplicationQuit");
            for (int j = 0; j < acceptUpdatedObjectList.Count; j++)
            {
                ApolloObject obj = acceptUpdatedObjectList[j];
                obj.OnApplicationQuit();
            }
            acceptUpdatedObjectList.Clear();

            ClearObjects();

            gcloud_quit();
        }
示例#12
0
        static void onSendVoidMethod(UInt64 objectId, int methodId)
        {
            ADebug.Log("onSendVoidMethod objectID:" + objectId + " methodID:" + methodId);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null)
            {
                obj.PerformVoidMethodWithId(methodId);
            }
            else
            {
                ADebug.LogError("onSendVoidMethod:" + objectId + " do not exist");
            }
        }
示例#13
0
        public void AddObject(ApolloObject obj)
        {
            if (obj == null)
            {
                return;
            }

            if (!dictObjectCollection.ContainsKey(obj.ObjectId))
            {
                dictObjectCollection.Add(obj.ObjectId, obj);

                //ADebug.Log("ApolloObjectManager AddObject:" + obj.ObjectId + " name:" + obj.GetType().FullName);
                addPlatformObject(obj.ObjectId, obj.GetType().FullName);
                //ADebug.Log("ApolloObjectManager after addApolloObject");
            }
        }
示例#14
0
        static void onSendResultStruct(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr resultBuffer, int resultLen)
        {
            ADebug.Log("onSendResultStruct enter:" + function + " " + objectId);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();


                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(Result) }, null);
                if (method != null)
                {
                    Result result    = Result.Unknown;
                    byte[] resultBuf = new byte[resultLen];
                    if (resultBuffer != IntPtr.Zero && resultLen > 0)
                    {
                        Marshal.Copy(resultBuffer, resultBuf, 0, resultLen);

                        if (!result.Decode(resultBuf))
                        {
                            ADebug.LogError("onSendResultStruct decode Error");
                            return;
                        }
                    }
                    else
                    {
                        ADebug.LogError("onSendResultStruct param Error");
                    }

                    method.Invoke(obj, new object[] { result });
                    //ADebug.Log("onSendStruct success");
                }
                else
                {
                    ADebug.LogError("onSendResult not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendResult:" + objectId + " do not exist");
            }
        }