Beispiel #1
0
 private void OnDisable()
 {
     if (this.m_ReflectionTexture)
     {
         Object.DestroyImmediate(this.m_ReflectionTexture);
         this.m_ReflectionTexture = null;
     }
     if (this.m_RefractionTexture)
     {
         Object.DestroyImmediate(this.m_RefractionTexture);
         this.m_RefractionTexture = null;
     }
     using (IDictionaryEnumerator enumerator = this.m_ReflectionCameras.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.get_Current();
             Object.DestroyImmediate(((Camera)dictionaryEntry.get_Value()).get_gameObject());
         }
     }
     this.m_ReflectionCameras.Clear();
     using (IDictionaryEnumerator enumerator2 = this.m_RefractionCameras.GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             DictionaryEntry dictionaryEntry2 = (DictionaryEntry)enumerator2.get_Current();
             Object.DestroyImmediate(((Camera)dictionaryEntry2.get_Value()).get_gameObject());
         }
     }
     this.m_RefractionCameras.Clear();
 }
Beispiel #2
0
        public string CallGame(uint callId, LuaTable luatable)
        {
            string result2 = string.Empty;

            if (string.IsNullOrEmpty(luatable["type"].ToString()))
            {
                return(result2);
            }
            Logger.DEBUG(string.Concat(new object[]
            {
                "callId=",
                callId.ToString(),
                " type=",
                luatable["type"]
            }));
            Action <string> action = delegate(string result)
            {
                CSharpInterface.ExecCallback(callId, result);
            };
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            using (IDictionaryEnumerator enumerator = luatable.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.get_Current();
                    dictionary.Add(dictionaryEntry.get_Key().ToString(), dictionaryEntry.get_Value());
                }
            }
            if (this.callbackForCallGame != null)
            {
                result2 = this.callbackForCallGame.Invoke(dictionary, action);
            }
            return(result2);
        }
Beispiel #3
0
 private static void WriteJson(IJsonWrapper obj, JsonWriter writer)
 {
     if (obj.IsString)
     {
         writer.Write(obj.GetString());
         return;
     }
     if (obj.IsBoolean)
     {
         writer.Write(obj.GetBoolean());
         return;
     }
     if (obj.IsDouble)
     {
         writer.Write(obj.GetDouble());
         return;
     }
     if (obj.IsInt)
     {
         writer.Write(obj.GetInt());
         return;
     }
     if (obj.IsLong)
     {
         writer.Write(obj.GetLong());
         return;
     }
     if (obj.IsArray)
     {
         writer.WriteArrayStart();
         IEnumerator enumerator = obj.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 object current = enumerator.get_Current();
                 JsonData.WriteJson((JsonData)current, writer);
             }
         }
         finally
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         writer.WriteArrayEnd();
         return;
     }
     if (obj.IsObject)
     {
         writer.WriteObjectStart();
         IDictionaryEnumerator enumerator2 = obj.GetEnumerator();
         try
         {
             while (enumerator2.MoveNext())
             {
                 DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator2.get_Current();
                 writer.WritePropertyName((string)dictionaryEntry.get_Key());
                 JsonData.WriteJson((JsonData)dictionaryEntry.get_Value(), writer);
             }
         }
         finally
         {
             IDisposable disposable2 = enumerator2 as IDisposable;
             if (disposable2 != null)
             {
                 disposable2.Dispose();
             }
         }
         writer.WriteObjectEnd();
         return;
     }
 }
 private static object CloneValue(object src, Type type)
 {
     if (src != null && type != typeof(string) && type.get_IsClass())
     {
         if (!type.get_IsGenericType())
         {
             return(GeneralUtils.CloneClass(src, type));
         }
         if (src is IDictionary)
         {
             IDictionary           dictionary  = src as IDictionary;
             IDictionary           dictionary2 = GeneralUtils.CreateNewType(type) as IDictionary;
             Type                  type2       = type.GetGenericArguments()[0];
             Type                  type3       = type.GetGenericArguments()[1];
             IDictionaryEnumerator enumerator  = dictionary.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.get_Current();
                     dictionary2.Add(GeneralUtils.CloneValue(dictionaryEntry.get_Key(), type2), GeneralUtils.CloneValue(dictionaryEntry.get_Value(), type3));
                 }
             }
             finally
             {
                 IDisposable disposable = enumerator as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
             return(dictionary2);
         }
         if (src is IList)
         {
             IList       list        = src as IList;
             IList       list2       = GeneralUtils.CreateNewType(type) as IList;
             Type        type4       = type.GetGenericArguments()[0];
             IEnumerator enumerator2 = list.GetEnumerator();
             try
             {
                 while (enumerator2.MoveNext())
                 {
                     object current = enumerator2.get_Current();
                     list2.Add(GeneralUtils.CloneValue(current, type4));
                 }
             }
             finally
             {
                 IDisposable disposable2 = enumerator2 as IDisposable;
                 if (disposable2 != null)
                 {
                     disposable2.Dispose();
                 }
             }
             return(list2);
         }
     }
     return(src);
 }
    private void Start()
    {
        Component[] componentsInChildren = base.GetComponentsInChildren(typeof(MeshFilter));
        Matrix4x4   worldToLocalMatrix   = base.get_transform().get_worldToLocalMatrix();
        Hashtable   hashtable            = new Hashtable();

        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            MeshFilter meshFilter = (MeshFilter)componentsInChildren[i];
            Renderer   renderer   = componentsInChildren[i].get_renderer();
            MeshCombineUtility.MeshInstance meshInstance = default(MeshCombineUtility.MeshInstance);
            meshInstance.mesh = meshFilter.get_sharedMesh();
            if (renderer != null && renderer.get_enabled() && meshInstance.mesh != null)
            {
                meshInstance.transform = worldToLocalMatrix * meshFilter.get_transform().get_localToWorldMatrix();
                Material[] sharedMaterials = renderer.get_sharedMaterials();
                for (int j = 0; j < sharedMaterials.Length; j++)
                {
                    meshInstance.subMeshIndex = Math.Min(j, meshInstance.mesh.get_subMeshCount() - 1);
                    ArrayList arrayList = (ArrayList)hashtable.get_Item(sharedMaterials[j]);
                    if (arrayList != null)
                    {
                        arrayList.Add(meshInstance);
                    }
                    else
                    {
                        arrayList = new ArrayList();
                        arrayList.Add(meshInstance);
                        hashtable.Add(sharedMaterials[j], arrayList);
                    }
                }
                renderer.set_enabled(false);
            }
        }
        using (IDictionaryEnumerator enumerator = hashtable.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                DictionaryEntry dictionaryEntry            = (DictionaryEntry)enumerator.get_Current();
                ArrayList       arrayList2                 = (ArrayList)dictionaryEntry.get_Value();
                MeshCombineUtility.MeshInstance[] combines = (MeshCombineUtility.MeshInstance[])arrayList2.ToArray(typeof(MeshCombineUtility.MeshInstance));
                if (hashtable.get_Count() == 1)
                {
                    if (base.GetComponent(typeof(MeshFilter)) == null)
                    {
                        base.get_gameObject().AddComponent(typeof(MeshFilter));
                    }
                    if (!base.GetComponent("MeshRenderer"))
                    {
                        base.get_gameObject().AddComponent("MeshRenderer");
                    }
                    MeshFilter meshFilter2 = (MeshFilter)base.GetComponent(typeof(MeshFilter));
                    meshFilter2.set_mesh(MeshCombineUtility.Combine(combines, this.generateTriangleStrips));
                    base.get_renderer().set_material((Material)dictionaryEntry.get_Key());
                    base.get_renderer().set_enabled(true);
                }
                else
                {
                    GameObject gameObject = new GameObject("Combined mesh");
                    gameObject.get_transform().set_parent(base.get_transform());
                    gameObject.get_transform().set_localScale(Vector3.get_one());
                    gameObject.get_transform().set_localRotation(Quaternion.get_identity());
                    gameObject.get_transform().set_localPosition(Vector3.get_zero());
                    gameObject.AddComponent(typeof(MeshFilter));
                    gameObject.AddComponent("MeshRenderer");
                    gameObject.get_renderer().set_material((Material)dictionaryEntry.get_Key());
                    MeshFilter meshFilter3 = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter));
                    meshFilter3.set_mesh(MeshCombineUtility.Combine(combines, this.generateTriangleStrips));
                }
            }
        }
    }
Beispiel #6
0
        private static void WriteValue(object obj, JsonWriter writer, bool writer_is_private, int depth)
        {
            if (depth > JsonMapper.max_nesting_depth)
            {
                throw new JsonException(string.Format("Max allowed object depth reached while trying to export from type {0}", obj.GetType()));
            }
            if (obj == null)
            {
                writer.Write(null);
                return;
            }
            if (obj is IJsonWrapper)
            {
                if (writer_is_private)
                {
                    writer.TextWriter.Write(((IJsonWrapper)obj).ToJson());
                }
                else
                {
                    ((IJsonWrapper)obj).ToJson(writer);
                }
                return;
            }
            if (obj is string)
            {
                writer.Write((string)obj);
                return;
            }
            if (obj is double)
            {
                writer.Write((double)obj);
                return;
            }
            if (obj is int)
            {
                writer.Write((int)obj);
                return;
            }
            if (obj is bool)
            {
                writer.Write((bool)obj);
                return;
            }
            if (obj is long)
            {
                writer.Write((long)obj);
                return;
            }
            if (obj is Array)
            {
                writer.WriteArrayStart();
                IEnumerator enumerator = ((Array)obj).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        object current = enumerator.get_Current();
                        JsonMapper.WriteValue(current, writer, writer_is_private, depth + 1);
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                writer.WriteArrayEnd();
                return;
            }
            if (obj is IList)
            {
                writer.WriteArrayStart();
                IEnumerator enumerator2 = ((IList)obj).GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        object current2 = enumerator2.get_Current();
                        JsonMapper.WriteValue(current2, writer, writer_is_private, depth + 1);
                    }
                }
                finally
                {
                    IDisposable disposable2 = enumerator2 as IDisposable;
                    if (disposable2 != null)
                    {
                        disposable2.Dispose();
                    }
                }
                writer.WriteArrayEnd();
                return;
            }
            if (obj is IDictionary)
            {
                writer.WriteObjectStart();
                IDictionaryEnumerator enumerator3 = ((IDictionary)obj).GetEnumerator();
                try
                {
                    while (enumerator3.MoveNext())
                    {
                        DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator3.get_Current();
                        writer.WritePropertyName((string)dictionaryEntry.get_Key());
                        JsonMapper.WriteValue(dictionaryEntry.get_Value(), writer, writer_is_private, depth + 1);
                    }
                }
                finally
                {
                    IDisposable disposable3 = enumerator3 as IDisposable;
                    if (disposable3 != null)
                    {
                        disposable3.Dispose();
                    }
                }
                writer.WriteObjectEnd();
                return;
            }
            Type type = obj.GetType();

            if (JsonMapper.custom_exporters_table.ContainsKey(type))
            {
                ExporterFunc exporterFunc = JsonMapper.custom_exporters_table.get_Item(type);
                exporterFunc(obj, writer);
                return;
            }
            if (JsonMapper.base_exporters_table.ContainsKey(type))
            {
                ExporterFunc exporterFunc2 = JsonMapper.base_exporters_table.get_Item(type);
                exporterFunc2(obj, writer);
                return;
            }
            if (obj is Enum)
            {
                Type underlyingType = Enum.GetUnderlyingType(type);
                if (underlyingType == typeof(long) || underlyingType == typeof(uint) || underlyingType == typeof(ulong))
                {
                    writer.Write((ulong)obj);
                }
                else
                {
                    writer.Write((int)obj);
                }
                return;
            }
            JsonMapper.AddTypeProperties(type);
            IList <PropertyMetadata> list = JsonMapper.type_properties.get_Item(type);

            writer.WriteObjectStart();
            using (IEnumerator <PropertyMetadata> enumerator4 = list.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    PropertyMetadata current3 = enumerator4.get_Current();
                    if (current3.IsField)
                    {
                        writer.WritePropertyName(current3.Info.get_Name());
                        JsonMapper.WriteValue(((FieldInfo)current3.Info).GetValue(obj), writer, writer_is_private, depth + 1);
                    }
                    else
                    {
                        PropertyInfo propertyInfo = (PropertyInfo)current3.Info;
                        if (propertyInfo.get_CanRead())
                        {
                            writer.WritePropertyName(current3.Info.get_Name());
                            JsonMapper.WriteValue(propertyInfo.GetValue(obj, null), writer, writer_is_private, depth + 1);
                        }
                    }
                }
            }
            writer.WriteObjectEnd();
        }
        private void SerializeDictionary(JsonWriter writer, IWrappedDictionary values, JsonDictionaryContract contract, JsonProperty member, JsonContract collectionValueContract)
        {
            contract.InvokeOnSerializing(values.UnderlyingDictionary, base.Serializer.Context);
            this.SerializeStack.Add(values.UnderlyingDictionary);
            writer.WriteStartObject();
            bool?isReference = contract.IsReference;
            bool flag        = (!isReference.get_HasValue()) ? this.HasFlag(base.Serializer.PreserveReferencesHandling, PreserveReferencesHandling.Objects) : isReference.get_Value();

            if (flag)
            {
                writer.WritePropertyName("$id");
                writer.WriteValue(base.Serializer.ReferenceResolver.GetReference(this, values.UnderlyingDictionary));
            }
            if (this.ShouldWriteType(TypeNameHandling.Objects, contract, member, collectionValueContract))
            {
                this.WriteTypeProperty(writer, values.UnderlyingDictionary.GetType());
            }
            JsonContract          collectionValueContract2 = base.Serializer.ContractResolver.ResolveContract(contract.DictionaryValueType ?? typeof(object));
            int                   top        = writer.Top;
            IDictionaryEnumerator enumerator = values.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    DictionaryEntry entry = (DictionaryEntry)enumerator.get_Current();
                    string          text  = this.GetPropertyName(entry);
                    text = ((contract.PropertyNameResolver == null) ? text : contract.PropertyNameResolver.Invoke(text));
                    try
                    {
                        object       value        = entry.get_Value();
                        JsonContract contractSafe = this.GetContractSafe(value);
                        if (this.ShouldWriteReference(value, null, contractSafe))
                        {
                            writer.WritePropertyName(text);
                            this.WriteReference(writer, value);
                        }
                        else if (this.CheckForCircularReference(value, default(ReferenceLoopHandling?), contract))
                        {
                            writer.WritePropertyName(text);
                            this.SerializeValue(writer, value, contractSafe, null, collectionValueContract2);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (!base.IsErrorHandled(values.UnderlyingDictionary, contract, text, ex))
                        {
                            throw;
                        }
                        this.HandleError(writer, top);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            writer.WriteEndObject();
            this.SerializeStack.RemoveAt(this.SerializeStack.get_Count() - 1);
            contract.InvokeOnSerialized(values.UnderlyingDictionary, base.Serializer.Context);
        }