/// <summary> /// /// </summary> /// <param name="entity"></param> /// <param name="item"></param> /// <param name="effect"></param> /// <param name="targetId"></param> /// <param name="targetCell"></param> /// <returns></returns> public override bool ProcessItem(CharacterEntity character, ItemDAO item, GenericEffect effect, long targetId, int targetCell) { return(Process(character, new Dictionary <string, string>() { { "statsId", effect.Id.ToString() }, { "value", effect.RandomJet.ToString() } })); }
public void SpawnEffect(GenericEffect data) { GameObject FXClone = Instantiate(EffectsList[data.index], data.position, Quaternion.identity); FXClone.transform.SetParent(transform); spawnedEffects.Add(FXClone); }
void Die() { isDead = true; gameObject.SetActive(false); GenericEffect explosionFX = new GenericEffect(1, transform.position); VFXManager.instance.SpawnEffect(explosionFX); VFXManager.instance.Poof(transform.position); AudioManager.instance.PlayCachedSound(AudioManager.instance.ExplosionSounds, transform.position, 0.2f); CameraManager.instance.Shake(0.2f); LevelManager.instance.AddCount(); }
void Die() { if (!dead) { dead = true; gameObject.SetActive(false); GenericEffect explosionFX = new GenericEffect(1, transform.position); VFXManager.instance.SpawnEffect(explosionFX); VFXManager.instance.Poof(transform.position); AudioManager.instance.PlaySoundAtLocation(AudioManager.instance.EnemySounds[0], 0.2f, transform.position); CameraManager.instance.Shake(0.2f); LevelManager.instance.AddCount(); } }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="item"></param> /// <param name="effect"></param> /// <param name="targetId"></param> /// <param name="targetCell"></param> /// <returns></returns> public override bool ProcessItem(CharacterEntity character, ItemDAO item, GenericEffect effect, long targetId, int targetCell) { if (targetId != -1) { var entity = character.Map.GetEntity(targetId); character = entity as CharacterEntity; if (character == null) { return(false); } } switch ((ItemTypeEnum)item.Template.Type) { case ItemTypeEnum.TYPE_PAIN: character.EmoteUse(EMOTE_EAT_REST); break; } return(Process(character, new Dictionary <string, string> { { "life", effect.RandomJet.ToString() } })); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <param name="item"></param> /// <param name="effect"></param> /// <param name="targetId"></param> /// <param name="targetCell"></param> /// <returns></returns> public override bool ProcessItem(CharacterEntity character, ItemDAO item, GenericEffect effect, long targetId, int targetCell) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="item"></param> /// <param name="effect"></param> /// <param name="targetId"></param> /// <param name="targetCell"></param> /// <returns></returns> public abstract bool ProcessItem(CharacterEntity character, ItemDAO item, GenericEffect effect, long targetId, int targetCell);
private static void PrepareEffectForRendering(PositionedModel model, GenericEffect effect)
private void DrawModel(Camera camera, PositionedModel model, RenderMode renderMode) { #if PROFILE ModelsDrawnThisFrame++; #endif //TimeManager.SumTimeSection("Draw Model Start"); bool flipped = model.FlipX ^ model.FlipY ^ model.FlipZ; #if XNA4 SetCullStateForModel(model, flipped); #else if (model.mDrawWireframe) FlatRedBallServices.GraphicsDevice.RenderState.FillMode = FillMode.WireFrame; switch (model.FaceCullMode) { case ModelFaceCullMode.CullClockwiseFace: if (!flipped) Renderer.GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace; else Renderer.GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace; break; case ModelFaceCullMode.CullCounterClockwiseFace: if (!flipped) Renderer.GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace; else Renderer.GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace; break; case ModelFaceCullMode.None: Renderer.GraphicsDevice.RenderState.CullMode = CullMode.None; break; } #region Reset device settings if they've changed - They may change in a shader FlatRedBallServices.GraphicsDevice.RenderState.DepthBufferEnable = true; FlatRedBallServices.GraphicsDevice.RenderState.DepthBufferWriteEnable = true; #endregion #endif //TimeManager.SumTimeSection("Set depth states"); #if XNA4 // I don't think we need to worry about vertex declarations #else #region Set Vertex Declaration if (model.XnaModel != null) { if (model.XnaModel.Meshes.Count != 0 && model.XnaModel.Meshes[0].MeshParts.Count != 0) { // The assumption is that each mesh part is using the same vertex declaration for the // whole model. Instead of setting the vertex declaration in the DrawMeshPart method we'll // set it up here to save on the number of method calls on the 360. FlatRedBallServices.GraphicsDevice.VertexDeclaration = model.XnaModel.Meshes[0].MeshParts[0].VertexDeclaration; } } #endregion #endif //TimeManager.SumTimeSection("Set vertex declaration"); #region Set Point Light // Find the closest light //int lightIndex = 0; //float distance; Vector3 meshCenter = (model == null) ? Vector3.Zero : model.Position; #endregion #region Draw Model #if WINDOWS_PHONE if (model.XnaModel != null) { model.XnaModel.CopyAbsoluteBoneTransformsTo(transforms); Matrix transformationMatrixFlippedAsNeeded = model.TransformationMatrix; foreach (ModelMeshXna mesh in model.XnaModel.Meshes) { for( int iCurEffect = 0; iCurEffect < mesh.Effects.Count; ++iCurEffect ) { GenericEffect effect = new GenericEffect( mesh.Effects[ iCurEffect ] ); ApplyColorOperation(model, effect); effect.EnableDefaultLighting(); // Set this to false and all is fixed magically! effect.VertexColorEnabled = false; SpriteManager.Camera.SetDeviceViewAndProjection(effect, false); // World can be used to set the mesh's transform effect.World = transforms[mesh.ParentBone.Index] * transformationMatrixFlippedAsNeeded; } mesh.Draw(); } } else if (model.CustomModel != null) { RenderCustomModel(model); } #else #region If using Custom Effect if (model.CustomEffect != null) { // Set technique here if using custom effect model.CustomEffect.SetParameterValues(); EffectTechnique technique = model.EffectCache.GetTechnique( model.CustomEffect.Effect, Renderer.EffectTechniqueNames[(int)renderMode]); if (technique == null && renderMode == RenderMode.Default) { technique = model.CustomEffect.Effect.Techniques[0]; } if (technique != null) { // Draw meshes only if custom effect has the required technique model.CustomEffect.Effect.CurrentTechnique = technique; DrawModelMeshes(camera, model, renderMode); } } #endregion else if (model.CustomModel != null) { RenderCustomModel(model); } else { // Just draw the meshes DrawModelMeshes(camera, model, renderMode); } #endif #endregion //TimeManager.SumTimeSection("DrawModelMeshes"); if (model.mDrawWireframe) { #if XNA4 throw new NotImplementedException(); #else FlatRedBallServices.GraphicsDevice.RenderState.FillMode = FillMode.Solid; #endif } }
private static void ApplyLighting(PositionedModel model, GenericEffect effect) { if (!LightManager.EnableLighting) { effect.LightingEnabled = false; } else if (AvailableLights != null && AvailableLights.Count > 0) { //effect.EnableDefaultLighting(); //Start by turning off all the lights. effect.LightingEnabled = true; effect.DirectionalLight0.Enabled = effect.DirectionalLight1.Enabled = effect.DirectionalLight2.Enabled = false; //This tracks which directional light in the shader we are working with. int effectLightIndex = 0; //Loop through all lights for (int i = 0; i < AvailableLights.Count; i++) { LightBase baseLight = AvailableLights[i]; if (baseLight.Enabled) { if (baseLight is AmbientLight) { SetAmbientLight(effect, baseLight); } else { Microsoft.Xna.Framework.Graphics.DirectionalLight directionalLight; if (effectLightIndex == 0) directionalLight = effect.DirectionalLight0; else if (effectLightIndex == 1) directionalLight = effect.DirectionalLight1; else directionalLight = effect.DirectionalLight2; SetDirectionalLight(directionalLight, baseLight, model.Position); effectLightIndex++; } } } } else { effect.EnableDefaultLighting(); effect.DirectionalLight0.Enabled = effect.DirectionalLight1.Enabled = effect.DirectionalLight2.Enabled = false; effect.AmbientLightColor = Vector3.Zero; } }
private static void ApplyColorOperation(PositionedModel model, GenericEffect effect) #endif { switch (model.ColorOperation) { case ColorOperation.None: effect.EmissiveColor = Vector3.Zero; effect.DiffuseColor = Vector3.One; effect.Alpha = model.Alpha; effect.TextureEnabled = true; break; case ColorOperation.Add: effect.EmissiveColor = new Vector3(model.Red, model.Green, model.Blue); effect.DiffuseColor = Vector3.Zero; effect.Alpha = model.Alpha; effect.TextureEnabled = true; break; case ColorOperation.Modulate: effect.EmissiveColor = Vector3.Zero; effect.DiffuseColor = new Vector3(model.Red, model.Green, model.Blue); effect.Alpha = model.Alpha; effect.TextureEnabled = true; break; case ColorOperation.Color: effect.EmissiveColor = Vector3.Zero; effect.DiffuseColor = new Vector3(model.Red, model.Green, model.Blue); effect.Alpha = model.Alpha; effect.TextureEnabled = false; break; default: throw new NotImplementedException("Models do not support the color operation " + model.ColorOperation); //break; } }
protected static void SetAmbientLight(GenericEffect effect, LightBase light) { effect.AmbientLightColor = light.DiffuseColor; }