public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { if (manifest.Properties.ContainsKey(ManifestKeys.SPEED)) { mSpeed = (float)(manifest.Properties[ManifestKeys.SPEED]); } if (manifest.Properties.ContainsKey(ManifestKeys.DAMAGE)) { mDamage = (int)(manifest.Properties[ManifestKeys.DAMAGE]); } Owner.ComponentsCreated += ComponentsCreatedHandler; GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { Effect genericEffect = contentLoader.Load <Effect>("shaders\\PhongShadow"); // If we have several of these objects, the content manager will return // a single shared effect instance to them all. But we want to preconfigure // the effect with parameters that are specific to this particular // object. By cloning the effect, we prevent one // from stomping over the parameter settings of another. Effect = genericEffect.Clone(); mTexture = contentLoader.Load <Texture>((string)(manifest.Properties[ManifestKeys.TEXTURE])); base.Initialize(contentLoader, manifest); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { string skillAssetName = (string)(manifest.Properties[ManifestKeys.RANGED_SKILL_ASSET_NAME]); ComponentManifest weaponManifest = contentLoader.Load <ComponentManifest>(Path.Combine("skills", skillAssetName)); Type weaponType = Type.GetType(weaponManifest.TypeFullName); object[] basicCtorParams = new object[] { Owner.Id }; RangedSkill = Activator.CreateInstance(weaponType, basicCtorParams) as BipedWeapon; RangedSkill.Initialize(contentLoader, weaponManifest); skillAssetName = (string)(manifest.Properties[ManifestKeys.MELEE_SKILL_ASSET_NAME]); weaponManifest = contentLoader.Load <ComponentManifest>(Path.Combine("skills", skillAssetName)); weaponType = Type.GetType(weaponManifest.TypeFullName); MeleeSkill = Activator.CreateInstance(weaponType, basicCtorParams) as BipedWeapon; MeleeSkill.Initialize(contentLoader, weaponManifest); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { float radius = (float)(manifest.Properties[ManifestKeys.RADIUS]); if (manifest.Properties.ContainsKey(ManifestKeys.MASS)) { float mass = (float)(manifest.Properties[ManifestKeys.MASS]); mSimSphere = new Sphere(BEPUutilities.Vector3.Zero, radius, mass); } else { mSimSphere = new Sphere(BEPUutilities.Vector3.Zero, radius); } base.Initialize(contentLoader, manifest); }
private void LoadSkill(int equipSlot) { if (mCharacterInfo.EquippedInventory[equipSlot] != null) { string assetName = mCharacterInfo.EquippedInventory[equipSlot].EquippedBehaviorAssetName; object[] basicCtorParams = new object[] { Owner.Id }; ComponentManifest skillManifest = mContentLoader.Load <ComponentManifest>(Path.Combine("skills", assetName)); Type skillType = Type.GetType(skillManifest.TypeFullName); Skills[equipSlot - EquipSlot.SKILL1] = Activator.CreateInstance(skillType, basicCtorParams) as ISkill; Skills[equipSlot - EquipSlot.SKILL1].Initialize(mContentLoader, skillManifest); } else { Skills[equipSlot - EquipSlot.SKILL1] = null; } }
/// <summary> /// Loads the components from the specified manifest string /// </summary> /// <param name="componentsElement">The manifest.</param> /// <returns>List<ComponentManifest>.</returns> public static List <ComponentManifest> DeserializeComponents(XElement componentsElement) { List <ComponentManifest> list = new List <ComponentManifest>(); if (componentsElement != null) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(ComponentManifest), XmlNames.ProjectManifestNamespace); foreach (XElement xElement in componentsElement.Elements()) { ComponentManifest item = Deserialize(xmlSerializer, xElement); list.Add(item); } } return(list); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { TerrainAsset = contentLoader.Load <Terrain>((string)(manifest.Properties[ManifestKeys.TERRAIN])); Heights = TerrainAsset.GetGeometry(); EffectRegistry.Add(TerrainAsset.Effect, (RenderOptions)(TerrainAsset.Tag)); mDefaultMaterial = new EffectApplication(TerrainAsset.Effect, RenderStatePresets.Default); mDefaultMaterial.AddParamSetter(new CommonParamSetter()); mDefaultMaterial.AddParamSetter(new ShadowParamSetter()); mDefaultMaterial.AddParamSetter(new HDRLightParamSetter()); mDefaultMaterial.AddParamSetter(new FogParamSetter()); mDepthOnlyMaterial = new EffectApplication(EffectRegistry.DepthOnlyFx, RenderStatePresets.Default); mDepthOnlyMaterial.AddParamSetter(new WorldViewProjParamSetter()); base.Initialize(contentLoader, manifest); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { float width = (float)(manifest.Properties[ManifestKeys.WIDTH]); float height = (float)(manifest.Properties[ManifestKeys.HEIGHT]); float length = (float)(manifest.Properties[ManifestKeys.LENGTH]); if (manifest.Properties.ContainsKey(ManifestKeys.MASS)) { float mass = (float)(manifest.Properties[ManifestKeys.MASS]); mSimBox = new Box(BEPUutilities.Vector3.Zero, width, height, length, mass); } else { mSimBox = new Box(BEPUutilities.Vector3.Zero, width, height, length); } base.Initialize(contentLoader, manifest); }
private static void ValidateProjectInfo(ProjectInfo scriptOne, string extension, string outputType, string assemblyName) { Assert.AreEqual("RepoCat Scripts", scriptOne.RepositoryInfo.RepositoryName); Assert.AreEqual(extension, scriptOne.TargetExtension); Assert.AreEqual(outputType, scriptOne.OutputType); Assert.AreEqual(assemblyName, scriptOne.AssemblyName); Assert.AreEqual("RepoCat Organization", scriptOne.RepositoryInfo.OrganizationName); DirectoryAssert.Exists(scriptOne.ProjectUri); FileAssert.Exists(scriptOne.DownloadLocation); Assert.IsFalse(string.IsNullOrEmpty(scriptOne.RepositoryStamp)); ComponentManifest feature = scriptOne.Components.Single(); FileAssert.Exists(feature.DocumentationUri); Assert.IsFalse(string.IsNullOrEmpty(feature.Description)); Assert.IsTrue(feature.Tags.Any()); Assert.IsTrue(feature.Properties.Any()); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { base.Initialize(contentLoader, manifest); if (manifest.Properties.ContainsKey(ManifestKeys.HEIGHT)) { mHeight = (float)(manifest.Properties[ManifestKeys.HEIGHT]); } if (manifest.Properties.ContainsKey(ManifestKeys.RADIUS)) { mRadius = (float)(manifest.Properties[ManifestKeys.RADIUS]); } if (manifest.Properties.ContainsKey(ManifestKeys.MASS)) { mMass = (float)(manifest.Properties[ManifestKeys.MASS]); } }
protected override void CreateSceneGraph(ComponentManifest manifest) { SceneGraph = new ActorTransformNode(Owner); SceneNode sphereParent = SceneGraph; Matrix modelAdjustment = Matrix.Identity; if (manifest.Properties.ContainsKey(ManifestKeys.MODEL_ADJUSTMENT)) { modelAdjustment = (Matrix)(manifest.Properties[ManifestKeys.MODEL_ADJUSTMENT]); } if (modelAdjustment != Matrix.Identity) { sphereParent = new StaticTransformNode(modelAdjustment); SceneGraph.AddChild(sphereParent); } BuildSphereAndGeometryNodes(manifest, sphereParent); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { if (manifest.Properties.ContainsKey(ManifestKeys.SCALE)) { mScale = (float)(manifest.Properties[ManifestKeys.SCALE]); } if (manifest.Properties.ContainsKey(ManifestKeys.ORIENTATION)) { mOrientation = (Quaternion)(manifest.Properties[ManifestKeys.ORIENTATION]); } if (manifest.Properties.ContainsKey(ManifestKeys.POSITION)) { mTranslation = (Vector3)(manifest.Properties[ManifestKeys.POSITION]); } if (manifest.Properties.ContainsKey(ManifestKeys.LOOKAT)) { mOrientation = Quaternion.CreateFromRotationMatrix( Matrix.Transpose(Matrix.CreateLookAt(Vector3.Zero, (Vector3)(manifest.Properties[ManifestKeys.LOOKAT]) - mTranslation, Vector3.Up))); } }
protected override void BuildSphereAndGeometryNodes(ComponentManifest manifest, SceneNode parent) { BoundingSphere bound = new BoundingSphere(); bound.Center = Vector3.Zero; // TODO: P2: Magic number? bound.Radius = 120.0f; ExplicitBoundingSphereNode meshBound = new ExplicitBoundingSphereNode(bound); parent.AddChild(meshBound); // Create the default material EffectApplication defaultMaterial = new EffectApplication(mEffect, mSettings.RenderState); defaultMaterial.AddParamSetter(new ParticlesParamSetter(delegate() { return(mCurrentTime); })); ParticleSystemGeometryNode geometry = new ParticleSystemGeometryNode(mParticleData, delegate() { mDrawCounter++; }, defaultMaterial); meshBound.AddChild(geometry); // It won't cast a shadow. geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, null); }
// If you override this, this one probably should get called _after_ the derived method does its stuff. public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { CreateSceneGraph(manifest); Owner.ComponentsCreated += ComponentsCreatedHandler; Owner.ActorInitialized += ActorInitializedHandler; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { Owner.ActorInitialized += ActorInitializedHandler; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { Owner.ComponentsCreated += ComponentsCreatedHandler; GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { base.Initialize(contentLoader, manifest); ProjectileTemplateName = (string)(manifest.Properties[ManifestKeys.PROJECTILE_NAME]); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { Owner.ActorInitialized += ActorInitializedHandler; GameResources.ActorManager.ProcessAIStep += ProcessAIStepHandler; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { Effect genericEffect = contentLoader.Load <Effect>("shaders\\Billboard"); // If we have several of these objects, the content manager will return // a single shared effect instance to them all. But we want to preconfigure // the effect with parameters that are specific to this particular // object. By cloning the effect, we prevent one // from stomping over the parameter settings of another. Effect = genericEffect.Clone(); Effect.CurrentTechnique = Effect.Techniques["Billboard"]; EffectRegistry.Add(Effect, RenderOptions.BillboardParams); EffectParameterCollection parameters = Effect.Parameters; // Set the values of parameters that do not change. parameters["WindAmount"].SetValue(0.0f); parameters["BillboardWidth"].SetValue(2.0f); parameters["BillboardHeight"].SetValue(2.0f); mTexture = contentLoader.Load <Texture>((string)(manifest.Properties[ManifestKeys.TEXTURE])); parameters["Texture"].SetValue(mTexture); parameters["gBright"].SetValue(0.17f); parameters["gContrast"].SetValue(0.9f); mDepthOnlyEffect = Effect.Clone(); mDepthOnlyEffect.CurrentTechnique = mDepthOnlyEffect.Techniques["DepthOnlyBillboard"]; EffectRegistry.Add(mDepthOnlyEffect, RenderOptions.BillboardParams); mGeometry = new MeshPart(); BillboardVertex[] vertices = new BillboardVertex[4]; vertices[0].Position = Vector3.Zero; vertices[1].Position = Vector3.Zero; vertices[2].Position = Vector3.Zero; vertices[3].Position = Vector3.Zero; vertices[0].Normal = Vector3.Up; vertices[1].Normal = Vector3.Up; vertices[2].Normal = Vector3.Up; vertices[3].Normal = Vector3.Up; vertices[0].TexCoord = Vector2.Zero; vertices[1].TexCoord = Vector2.UnitX; vertices[2].TexCoord = Vector2.One; vertices[3].TexCoord = Vector2.UnitY; float randValue = 0.5f; if (manifest.Properties.ContainsKey(ManifestKeys.IS_RANDOMIZED) && (bool)(manifest.Properties[ManifestKeys.IS_RANDOMIZED])) { randValue = (float)(GameResources.ActorManager.Random.Next(-524288, 524288)) / (float)524288; } vertices[0].Random = randValue; vertices[1].Random = randValue; vertices[2].Random = randValue; vertices[3].Random = randValue; mGeometry.VertexBuffer = new VertexBuffer( SharedResources.Game.GraphicsDevice, BillboardVertex.VertexDeclaration, 4, BufferUsage.None); mGeometry.VertexBuffer.SetData(vertices); // Create and populate the index buffer. ushort[] indices = new ushort[] { 0, 1, 2, 0, 2, 3 }; mGeometry.IndexBuffer = new IndexBuffer( SharedResources.Game.GraphicsDevice, typeof(ushort), indices.Length, BufferUsage.None); mGeometry.IndexBuffer.SetData(indices); mGeometry.NumVertices = 4; mGeometry.PrimitiveCount = 2; mGeometry.StartIndex = 0; mGeometry.VertexOffset = 0; GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdateHandler; base.Initialize(contentLoader, manifest); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { base.Initialize(contentLoader, manifest); Category = (SlotCategory)(manifest.Properties[ManifestKeys.EQUIP_SLOT_CATEGORY]); EquippedBehaviorAssetName = (string)(manifest.Properties[ManifestKeys.EQUIPPED_BEHAVIOR_NAME]); }
// Called after construction and having been added to the actor's component list. Override this to initialize the component's // properties and load assets using the ComponentManifest. public virtual void Initialize(ContentManager contentLoader, ComponentManifest manifest) { }
public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager contentLoader, ComponentManifest manifest) { SkyTexture = contentLoader.Load <TextureCube>((string)(manifest.Properties[ManifestKeys.TEXTURE])); OnEnvironmentMapAdded(EventArgs.Empty); base.Initialize(contentLoader, manifest); }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { Owner.ComponentsCreated += ComponentsCreatedHandler; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { base.Initialize(contentLoader, manifest); Damage = (int)(manifest.Properties[ManifestKeys.DAMAGE]); }
protected abstract void BuildSphereAndGeometryNodes(ComponentManifest manifest, SceneNode parent);
protected abstract void CreateSceneGraph(ComponentManifest manifest);
protected override void BuildSphereAndGeometryNodes(ComponentManifest manifest, SceneNode parent) { Vector4 specColor = (Vector4)(manifest.Properties[ManifestKeys.MAT_SPEC_COLOR]); Effect.Parameters[EffectRegistry.MATERIAL_SPECULAR_COLOR_PARAM_NAME].SetValue(specColor); Effect.Parameters[EffectRegistry.TEXTURE_PARAM_NAME].SetValue(mTexture); float brightness = 1.0f; if (manifest.Properties.ContainsKey(ManifestKeys.BRIGHTNESS)) { brightness = (float)(manifest.Properties[ManifestKeys.BRIGHTNESS]); } Effect.Parameters[EffectRegistry.BRIGHTNESS_PARAM_NAME].SetValue(brightness); float contrast = 1.0f; if (manifest.Properties.ContainsKey(ManifestKeys.CONTRAST)) { contrast = (float)(manifest.Properties[ManifestKeys.CONTRAST]); } Effect.Parameters[EffectRegistry.CONTRAST_PARAM_NAME].SetValue(contrast); // First, add the effect's params to the EffectRegistry so the ParamSetter can retrieve them. EffectRegistry.Add(Effect, RenderOptions.RequiresHDRLighting | RenderOptions.RequiresShadowMap); // Create the default material EffectApplication defaultMaterial = new EffectApplication(Effect, RenderStatePresets.Default); defaultMaterial.AddParamSetter(new CommonParamSetter()); defaultMaterial.AddParamSetter(new HDRLightParamSetter()); defaultMaterial.AddParamSetter(new FogParamSetter()); defaultMaterial.AddParamSetter(new ShadowParamSetter()); RawGeometryNode geometry = null; ExplicitBoundingSphereNode meshBound = null; switch ((Shape)(manifest.Properties[ManifestKeys.SHAPE])) { case Shape.Box: geometry = new RawGeometryNode(GeneratedGeometry.Box, defaultMaterial); meshBound = new ExplicitBoundingSphereNode(GeneratedGeometry.BoxBound); break; case Shape.Sphere: geometry = new RawGeometryNode(GeneratedGeometry.Sphere, defaultMaterial); meshBound = new ExplicitBoundingSphereNode(GeneratedGeometry.SphereBound); break; } parent.AddChild(meshBound); meshBound.AddChild(geometry); // Create the ShadowMap material // Default to CastsShadow = true if (!manifest.Properties.ContainsKey(ManifestKeys.CASTS_SHADOW) || (bool)(manifest.Properties[ManifestKeys.CASTS_SHADOW])) { EffectApplication depthOnlyMaterial; depthOnlyMaterial = new EffectApplication(EffectRegistry.DepthOnlyFx, RenderStatePresets.Default); depthOnlyMaterial.AddParamSetter(new WorldViewProjParamSetter()); geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, depthOnlyMaterial); } else { geometry.AddMaterial(TraversalContext.MaterialFlags.ShadowMap, null); } // If the GeometryNode requires additional materials, they would need to be added here. }
public virtual void Initialize(ContentManager contentLoader, ComponentManifest manifest) { ResourceCostToUse = (float)(manifest.Properties[ManifestKeys.RESOURCE_COST_TO_USE]); // TODO: P2: Init range info. GameResources.ActorManager.PreAnimationUpdateStep += PreAnimationUpdate; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { base.Initialize(contentLoader, manifest); Power = (int)(manifest.Properties[ManifestKeys.POWER]); }