Beispiel #1
0
        private static bool BuildColliderFromRecord
        (
            Dictionary <string, Transform> objectMap,
            IColliderSerializer colliderSerializer
        )
        {
            var gameObject = BuildTransformFromRecord(objectMap, colliderSerializer.GetBaseInfo().transform);
            var succeeded  = gameObject != null;

            if (succeeded)
            {
                colliderSerializer.BuildColliderComponent(gameObject);
            }
            return(succeeded);
        }
Beispiel #2
0
#pragma warning restore 0649

        // Parsing and verification

        private static IEnumerable <IColliderSerializer> SerializeColliderRecords
        (
            IEnumerable <TextRecordParsing.Record> sourceRecords,
            List <DynamicsSetup.ParseMessage> errorRecords
        )
        {
            var serializerClasses = new Dictionary <string, System.Type>
            {
                { SphereColliderToken, typeof(SphereColliderSerializer) },
                { CapsuleColliderToken, typeof(CapsuleColliderSerializer) },
                { PanelColliderToken, typeof(PanelColliderSerializer) },
            };

            var colliderSerializers = new List <IColliderSerializer>(sourceRecords.Count());

            foreach (var sourceRecord in sourceRecords)
            {
                IColliderSerializer        newColliderInfo = null;
                DynamicsSetup.ParseMessage error           = null;
                var baseInfo = DynamicsSetup.SerializeObjectFromStrings <ColliderSerializerBaseInfo>(sourceRecord.Items, null, ref error);
                if (baseInfo != null)
                {
                    System.Type serializerType;
                    if (serializerClasses.TryGetValue(baseInfo.colliderType, out serializerType))
                    {
                        newColliderInfo = DynamicsSetup.SerializeObjectFromStrings(
                            serializerType, sourceRecord.Items, "linkedRenderer", ref error)
                                          as IColliderSerializer;
                    }
                    else
                    {
                        error = new DynamicsSetup.ParseMessage("Invalid collider type: " + baseInfo.colliderType, sourceRecord.Items);
                    }
                }

                if (newColliderInfo != null)
                {
                    colliderSerializers.Add(newColliderInfo);
                }
                else
                {
                    errorRecords.Add(error);
                }
            }
            return(colliderSerializers);
        }