Exemplo n.º 1
0
        protected override JToken SerializeWithoutMetadata(ValueModel value)
        {
            ObjectModel             model      = value as ObjectModel;
            IEnumerable <JProperty> properties = model.GetProperties().Select(x => new JProperty(x.Name, _internalSerializer.Serialize(x.Model)));

            return(new JObject(properties));
        }
        public TurretAssembly Assemble(RootModel model)
        {
            GameObject     assemblyObject = UnityEngine.Object.Instantiate(Resources.Load <GameObject>(ASSEMBLY_PREFAB_PATH));
            TurretAssembly assembly       = assemblyObject.GetComponent <TurretAssembly>();
            ObjectModel    obj            = model.Root as ObjectModel;

            assembly.Name        = obj.GetValue <string>("Name");
            assembly.Description = obj.GetValue <string>("Description");
            ObjectModel tiers    = obj.GetObject("Tiers");
            UpgradeMap  upgrades = _valueAssembler.Assemble(obj.GetObject("UpgradeMap"), typeof(UpgradeMap), new AssemblyContext()) as UpgradeMap;

            foreach (var tierProperty in tiers.GetProperties())
            {
                Transform tierObj = AssembleTier(tierProperty.Model as ObjectModel, assembly).transform;
                Tier      tier    = Tier.Parse(tierProperty.Name);

                tierObj.gameObject.SetActive(false);
                tierObj.gameObject.name = tier.ToString();

                assembly.AddTier(tierObj, tier);
            }

            assembly.UpgradeMap = upgrades;
            assembly.SetTier(Tier.Initial);
            return(assembly);
        }
Exemplo n.º 3
0
        public override void Assemble(ObjectModel model, Renderer target, AssemblyContext context)
        {
            var properties = model.GetProperties();

            target.shadowCastingMode          = model.GetValue <ShadowCastingMode>("ShadowCastingMode");
            target.receiveShadows             = model.GetValue <bool>("RecieveShadows");
            target.lightProbeUsage            = model.GetValue <LightProbeUsage>("LightProbeUsage");
            target.reflectionProbeUsage       = model.GetValue <ReflectionProbeUsage>("ReflectionProbeUsage");
            target.motionVectorGenerationMode = model.GetValue <MotionVectorGenerationMode>("MotionVectorGenerationMode");
            target.allowOcclusionWhenDynamic  = model.GetValue <bool>("AllowOcclusionWhenDynamic");
            target.sortingLayerID             = model.GetValue <int>("SortingLayer");
            target.sortingOrder = model.GetValue <int>("OrderInLayer");
        }
Exemplo n.º 4
0
        public void Assemble(ValueModel source, AssemblyContext context)
        {
            ObjectModel obj = source as ObjectModel;

            _translations = obj.GetProperties().ToDictionary(x => x.Name, y => (y.Model as PrimitiveModel).Value);
        }