public void Assemble(ValueModel source, AssemblyContext context) { ObjectModel obj = source as ObjectModel; TierIndex = obj.GetValue <int>("Tier"); VariantIndex = obj.GetValue <int>("Variant"); }
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); }
public override Quaternion AssembleValue(ObjectModel value, AssemblyContext context) { return new Quaternion( value.GetValue<float>("X"), value.GetValue<float>("Y"), value.GetValue<float>("Z"), value.GetValue<float>("W")); }
public override Vector4 AssembleValue(ObjectModel value, AssemblyContext context) { return new Vector4( value.GetValue<float>("X"), value.GetValue<float>("Y"), value.GetValue<float>("Z"), value.GetValue<float>("W")); }
public override void Assemble(ObjectModel model, CircleCollider2D target, AssemblyContext context) { Vector2Assembler vs = new Vector2Assembler(); target.radius = model.GetValue <float>("Radius"); target.offset = vs.AssembleValue(model.GetObject("Offset"), context); target.isTrigger = model.GetValue <bool>("IsTrigger"); target.usedByEffector = model.GetValue <bool>("UsedByEffector"); }
public void Assemble(ValueModel source, AssemblyContext context) { ObjectModel model = source as ObjectModel; Identifier = model.GetValue <string>("Identifier"); IsCompleted = model.GetValue <bool>("IsCompleted"); CompletedOn = model.GetValue <DateTime>("CompletedOn"); Progression = model.GetProperty("Progression"); }
public override Rect AssembleValue(ObjectModel value, AssemblyContext context) { return(new Rect( value.GetValue <float>("X"), value.GetValue <float>("Y"), value.GetValue <float>("Width"), value.GetValue <float>("Height") )); }
public void Assemble(ValueModel source, AssemblyContext context) { ObjectModel obj = (source as ObjectModel); Name = obj.GetValue <string>("Name"); Description = obj.GetValue <string>("Description"); Identifier = obj.GetValue <string>("Identifier"); Width = obj.GetValue <int>("Width"); Height = obj.GetValue <int>("Height"); Tiles = AssembleTileData(obj.GetArray("Tiles"), context); Objects = obj.GetArray("Objects").Elements.Cast <ObjectModel>().ToArray(); }
public TurretComponent Assemble(ObjectModel model, Transform parent, TurretAssembly assembly, AssemblyContext context) { IContentCachedPrefab component = GetComponent(model.GetValue <string>("UniqueIdentifier")); ValueAssembler assembler = new ValueAssembler(); GameObject obj = component.Instantiate(); TurretComponent newComponent = obj.GetComponent <TurretComponent>(); if (parent != null) { obj.transform.SetParent(parent.transform); var position = (Vector2)assembler.Assemble(model.GetObject("LocalPosition"), typeof(Vector2), context); obj.transform.localPosition = (Vector3)position + Vector3.back * 0.1f; if (model.HasProperty("Angle")) { obj.transform.localRotation = Quaternion.Euler(0f, 0f, model.GetValue <float>("Angle")); } if (model.HasProperty("Flipped")) { if (model.GetValue <bool>("Flipped")) { newComponent.Flip(); } } TurretComponent parentComponent = parent.GetComponent <TurretComponent>(); foreach (var point in newComponent.AttachmentPoints) { AttachmentSlot slot = FindSlotForPoint(parentComponent.AttachmentSlots.GetSupportingPoints(point), point, obj.transform, parent.transform); if (slot != null) { slot.Attach(newComponent); } } } else { obj.transform.SetParent(assembly.transform); obj.transform.localPosition = Vector3.zero; } foreach (ValueModel child in model.GetArray("Children")) { Assemble(child as ObjectModel, newComponent.transform, assembly, context); } return(newComponent); }
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"); }
public override void Assemble(ObjectModel model, TrailRenderer target, AssemblyContext context) { ValueAssembler assembler = new ValueAssembler(); RendererAssembler baseAssembler = new RendererAssembler(); target.widthCurve = (AnimationCurve)assembler.Assemble(model.GetProperty("Curve"), typeof(AnimationCurve), context); target.time = model.GetValue <float>("Time"); target.minVertexDistance = model.GetValue <float>("MinVertexDistance"); target.autodestruct = model.GetValue <bool>("Autodestruct"); target.emitting = model.GetValue <bool>("Emitting"); target.colorGradient = (Gradient)assembler.Assemble(model.GetProperty("Color"), typeof(Gradient), context); target.numCornerVertices = model.GetValue <int>("CornerVertices"); target.numCapVertices = model.GetValue <int>("CapVertices"); target.alignment = model.GetValue <LineAlignment>("Alignment"); target.textureMode = model.GetValue <LineTextureMode>("TextureMode"); target.generateLightingData = model.GetValue <bool>("GenerateLigtingData"); target.shadowBias = model.GetValue <float>("ShadowBias"); baseAssembler.Assemble(model, target, context); }
public override Gradient AssembleValue(ObjectModel value, AssemblyContext context) { ColorAssembler assembler = new ColorAssembler(); Gradient gradient = new Gradient(); gradient.mode = value.GetValue <GradientMode>("Mode"); gradient.colorKeys = value.GetArray("ColorKeys").Select(x => new GradientColorKey((Color)assembler.Assemble((x as ObjectModel).GetObject("Color"), context), (x as ObjectModel).GetValue <float>("Time"))).ToArray(); gradient.alphaKeys = value.GetArray("AlphaKeys").Select(x => new GradientAlphaKey((x as ObjectModel).GetValue <float>("Alpha"), (x as ObjectModel).GetValue <float>("Time"))).ToArray(); return(gradient); }
private GameObject RecursiveAssemble(ObjectModel model, AssemblyContext context, Transform parent) { GameObject obj = new GameObject(model.GetValue <string>("Name")) { tag = model.GetValue <string>("Tag"), layer = model.GetValue <int>("Layer"), isStatic = model.GetValue <bool>("Static") }; Vector3 pos = obj.transform.position; Quaternion rot = obj.transform.rotation; Vector3 scale = obj.transform.localScale; obj.transform.SetParent(parent, true); obj.transform.localPosition = pos; obj.transform.localRotation = rot; obj.transform.localScale = scale; obj.SetActive(false); var components = model.GetArray("Components"); foreach (var component in components) { _componentAssembler.Assemble(component as ObjectModel, obj, context); } var children = model.GetArray("Children"); foreach (var child in children) { GameObject childObj = RecursiveAssemble(child as ObjectModel, context, obj.transform); } obj.SetActive(true); return(context.MakeReferencable(obj, model.Guid)); }
private Keyframe AssembleKeyframe(ObjectModel frameModel) { return(new Keyframe( frameModel.GetValue <float>("Time"), frameModel.GetValue <float>("Value"), frameModel.GetValue <float>("InTangent"), frameModel.GetValue <float>("OutTangent"), frameModel.GetValue <float>("InWeight"), frameModel.GetValue <float>("OutWeight") )); }
public override void Assemble(ObjectModel model, LineRenderer target, AssemblyContext context) { ValueAssembler assembler = new ValueAssembler(); RendererAssembler baseSerializer = new RendererAssembler(); target.positionCount = model.GetValue <int>("PositionCount"); SetPositions(target, model.GetArray("Positions").Select(x => (Vector3)assembler.Assemble(x, typeof(Vector3), context)).ToArray()); target.widthCurve = (AnimationCurve)assembler.Assemble(model.GetProperty("Curve"), typeof(AnimationCurve), context); target.colorGradient = (Gradient)assembler.Assemble(model.GetProperty("Colors"), typeof(Gradient), context); target.numCornerVertices = model.GetValue <int>("CornerVerticies"); target.numCapVertices = model.GetValue <int>("CapVerticies"); target.alignment = model.GetValue <LineAlignment>("Alignment"); target.textureMode = model.GetValue <LineTextureMode>("TextureMode"); target.shadowBias = model.GetValue <float>("ShadowBias"); target.generateLightingData = model.GetValue <bool>("GenerateLighingData"); target.useWorldSpace = model.GetValue <bool>("UseWorldSpace"); baseSerializer.Assemble(model, target, context); }
public override Color AssembleValue(ObjectModel value, AssemblyContext context) { return(new Color(value.GetValue <float>("Red"), value.GetValue <float>("Green"), value.GetValue <float>("Blue"), value.GetValue <float>("Alpha"))); }
public override void Assemble(ObjectModel model, Rigidbody2D target, AssemblyContext context) { target.bodyType = model.GetValue <RigidbodyType2D>("BodyType"); }
public override LayerMask AssembleValue(ObjectModel value, AssemblyContext context) { return(value.GetValue <int>("Mask")); }
public override Vector3Int AssembleValue(ObjectModel value, AssemblyContext context) { return new Vector3Int(value.GetValue<int>("X"), value.GetValue<int>("Y"), value.GetValue<int>("Z")); }