public static Effect CompileEffect( Device device, string effectFile ) { Effect effect = null; var compilationSucceeded = false; while ( !compilationSucceeded ) { try { if ( !File.Exists( effectFile ) ) { throw new Exception( "Effect file " + effectFile + " not found." ); } using ( var shaderBytecode = ShaderBytecode.CompileFromFile( effectFile, "fx_5_0", ShaderFlags.None, EffectFlags.None ) ) { effect = new Effect( device, shaderBytecode ); compilationSucceeded = true; } } catch ( Exception e ) { compilationSucceeded = false; throw new Exception( "Could not compile effect file " + effectFile + ":\n" + e.Message ); } } return effect; }
public static bool Parse(ref Tokenizer tokenizer, out Amulet result) { tokenizer.Expect(TokenName.OPEN_PARENTHESIS); List < int > temp; result = new Amulet(); result.effects = new List < Effect > (); result.jewel_ids = new List < int > (); if (tokenizer.ExpectIntegerList(out temp)) { if (temp.Count >= 2) { Effect effect = new Effect(); effect.skill_id = temp[0]; effect.points = temp[1]; result.effects.Add(effect); } if (temp.Count >= 4) { Effect effect = new Effect(); effect.skill_id = temp[2]; effect.points = temp[3]; result.effects.Add(effect); } } else { return false; } if (!tokenizer.ExpectIntegerList(out result.jewel_ids)) { return false; } return tokenizer.Expect(TokenName.CLOSE_PARENTHESIS); }
public void AddEffect(Effect effect) { UnityEngine.Assertions.Assert.IsNotNull(this.effects); effects.Add(effect); Rarity += ComputeRarity(effect); }
List<AudioClip> transformEfx; // Transform sound effects #endregion Fields #region Constructors /** * Constructor * * Arguments * - Player player - The owner of this ability */ public AlienPrimaryAbility(Player player) { GameObject alienModel = null, humanModel = null; // The models of the player AbilityName = "Alien Mode"; Range = 0.0; // No range AbilityRangeType = RangeType.GLOBALTARGETRANGE; AbilityActivationType = ActivationType.SUPPORTIVE; owner = player; /* * For the model, need to do many things, such as getting the game object of * the player's model */ foreach (Transform objectTransform in player.gameObject.transform) { if (objectTransform.gameObject.name.Equals("HybridHuman")) // Found human model humanModel = objectTransform.gameObject; else if (objectTransform.gameObject.name.Equals("alien")) // Found alien model alienModel = objectTransform.gameObject; if (alienModel != null && humanModel != null) break; } changeModel = new ModelChangeTurnEffect(alienModel, humanModel, owner.gameObject, "Alien Mode: Shape Change", "Icons/Effects/alienmodepurple", -1, false); secondaryEffectRewards = new List<Effect>(); transformEfx = new List<AudioClip>(); transformEfx.Add(Resources.Load<AudioClip>("Audio/Sound Effects/Alien_transform")); if (transformEfx.Count != 1) { Debug.LogError("Invalid sound effect path for alien transforming"); } }
public EffectParameterUpdaterLayout(GraphicsDevice graphicsDevice, Effect effect, DescriptorSetLayoutBuilder[] layouts) { Layouts = layouts; // Process constant buffers ResourceGroupLayouts = new ResourceGroupLayout[layouts.Length]; for (int layoutIndex = 0; layoutIndex < layouts.Length; layoutIndex++) { var layout = layouts[layoutIndex]; if (layout == null) continue; ParameterCollectionLayout.ProcessResources(layout); EffectConstantBufferDescription cbuffer = null; for (int entryIndex = 0; entryIndex < layout.Entries.Count; ++entryIndex) { var layoutEntry = layout.Entries[entryIndex]; if (layoutEntry.Class == EffectParameterClass.ConstantBuffer) { // For now we assume first cbuffer will be the main one if (cbuffer == null) { cbuffer = effect.Bytecode.Reflection.ConstantBuffers.First(x => x.Name == layoutEntry.Key.Name); ParameterCollectionLayout.ProcessConstantBuffer(cbuffer); } } } var resourceGroupDescription = new ResourceGroupDescription(layout, cbuffer); ResourceGroupLayouts[layoutIndex] = ResourceGroupLayout.New(graphicsDevice, resourceGroupDescription, effect.Bytecode); } }
private float glowStrength; // Strength of the glow. #endregion Fields #region Constructors /// <summary> /// Default Constructor. /// </summary> /// <param name="device">Copy of the rendering device.</param> /// <param name="effect">Copy of the effect class.</param> public EmissiveClass(Device device, Effect effect) { pathName = ""; this.device = device; this.effect = effect; glowStrength = 3.0f; }
protected VisualEffect(IServiceProvider services, string effectAsset, int effectLayerCount, IEnumerable<RenderTargetLayerType> requiredRenderTargets) { if (services == null) throw new ArgumentNullException("services"); if (effectAsset == null) throw new ArgumentNullException("effectAsset"); if (requiredRenderTargets == null) throw new ArgumentNullException("requiredRenderTargets"); if (effectLayerCount < 0) throw new ArgumentOutOfRangeException("affectedLayers", "Parameter should have non-negative value."); renderer = (Renderer)services.GetService(typeof(Renderer)); resourceManager = (ResourceManager)services.GetService(typeof(ResourceManager)); this.requiredRenderTargets = requiredRenderTargets; this.effectLayerCount = effectLayerCount > 0 ? effectLayerCount : renderer.KBufferManager.Configuration.LayerCount; effect = resourceManager.Load<Effect>(effectAsset); effectTechnique = effect.GetTechniqueByName(VisualEffectTechniqueName); if (!effectTechnique.IsValid) throw new ArgumentException( string.Format("Given effect asset '{0}' does not contain technique {1}.", effectAsset, VisualEffectTechniqueName), "effectAsset"); }
public int vertexStartIndex; // Start offset for VB #endregion Fields #region Methods public void Render(Effect effect, Device device, bool setMaterial) { // Set material if (setMaterial) material.ApplyMaterial(device); // Calculate number of primitives to draw. int primCount = 0; switch (Type) { case PrimitiveType.TriangleList: primCount = nIndices / 3; break; case PrimitiveType.TriangleFan: case PrimitiveType.TriangleStrip: primCount = nIndices - 2; break; } // Draw if (primCount > 0) { device.DrawIndexedPrimitives(Type, vertexStartIndex, lowestIndiceValue, nVerts, IndiceStartIndex, primCount); } }
protected override async Task LoadContent() { await base.LoadContent(); var view = Matrix.LookAtRH(new Vector3(2,2,2), new Vector3(0, 0, 0), Vector3.UnitY); var projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.ViewWidth / GraphicsDevice.BackBuffer.ViewHeight, 0.1f, 100.0f); worldViewProjection = Matrix.Multiply(view, projection); geometry = GeometricPrimitive.Cube.New(GraphicsDevice); simpleEffect = new Effect(GraphicsDevice, SpriteEffect.Bytecode); parameterCollection = new ParameterCollection(); parameterCollectionGroup = new EffectParameterCollectionGroup(GraphicsDevice, simpleEffect, new[] { parameterCollection }); parameterCollection.Set(TexturingKeys.Texture0, UVTexture); // TODO DisposeBy is not working with device reset offlineTarget0 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); offlineTarget1 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); offlineTarget2 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); depthBuffer = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.D16_UNorm, TextureFlags.DepthStencil).DisposeBy(this); width = GraphicsDevice.BackBuffer.ViewWidth; height = GraphicsDevice.BackBuffer.ViewHeight; }
protected override async Task LoadContent() { await base.LoadContent(); wireframeState = RasterizerState.New(GraphicsDevice, new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe }); simpleEffect = new Effect(GraphicsDevice, SpriteEffect.Bytecode); parameterCollection = new ParameterCollection(); parameterCollectionGroup = new EffectParameterCollectionGroup(GraphicsDevice, simpleEffect, new [] { parameterCollection }); parameterCollection.Set(TexturingKeys.Texture0, UVTexture); primitives = new List<GeometricPrimitive>(); // Creates all primitives primitives = new List<GeometricPrimitive> { GeometricPrimitive.Plane.New(GraphicsDevice), GeometricPrimitive.Cube.New(GraphicsDevice), GeometricPrimitive.Sphere.New(GraphicsDevice), GeometricPrimitive.GeoSphere.New(GraphicsDevice), GeometricPrimitive.Cylinder.New(GraphicsDevice), GeometricPrimitive.Torus.New(GraphicsDevice), GeometricPrimitive.Teapot.New(GraphicsDevice), GeometricPrimitive.Capsule.New(GraphicsDevice, 0.5f, 0.3f), GeometricPrimitive.Cone.New(GraphicsDevice) }; view = Matrix.LookAtRH(new Vector3(0, 0, 5), new Vector3(0, 0, 0), Vector3.UnitY); Window.AllowUserResizing = true; }
public void SetUp() { AppControl.SetUpApplication(); engine = new MultipleEffect3DEngine() { D3DDevice = new MultipleOutputDevice() { NumAdditionalTargets = 1 } }; effect = new WorldViewProjEffect() { ShaderFilename = @"Effects\ClipmapTerrain_w_GSOut.fx" }; engine.AddEffect(effect); hiresCtm = new ClipmapTerrainManager(engine, effect) { WidthInTiles = widthInTiles, WidthOfTiles = widthOfTiles, TextureVariableName = "HiresTexture", StartingLongLat = startingLongLat }; loresCtm = new ClipmapTerrainManager(engine, effect) { WidthInTiles = widthInTiles, WidthOfTiles = widthOfTiles, TextureVariableName = "LoresTexture", TerrainFetcher = new Srtm30TextureFetcher(), StartingLongLat = startingLongLat }; etm = new ExTerrainManager(engine,effect) { AutoAdjustScaleBasedOnHeight = true}; form = new D3DHostForm(); form.SetEngine(engine); }
protected override void InitializeCore() { base.InitializeCore(); backgroundEffect = new Effect(Context.GraphicsDevice, BackgroundEffect.Bytecode) { Name = "BackgroundEffect" }; spriteBatch = new SpriteBatch(Context.GraphicsDevice) { VirtualResolution = new Vector3(1)}; }
public GroundOnTimeAppliedEffect(int id, Effect effect, int nbTurn, Character caster) { _id = id; _effect = effect; _nbTurn = nbTurn; _caster = caster; }
void RenderModel(Graphics.Content.Model10 model, SlimDX.Matrix entityWorld, Effect effect) { throw new NotImplementedException(); //if (model == null || !model.Visible || model.Mesh == null) return; Matrix world = model.World * entityWorld; world.M41 = (float)((int)world.M41); world.M42 = (float)((int)world.M42); world *= Matrix.Scaling(2f / (float)view.Viewport.Width, 2f / (float)view.Viewport.Height, 1) * Matrix.Translation(-1, -1, 0) * Matrix.Scaling(1, -1, 1); world.M43 = 0.5f; effect.GetVariableByName("World").AsMatrix().SetMatrix(world); effect.GetVariableByName("Texture").AsResource().SetResource(model.TextureShaderView); effect.GetTechniqueByName("Render").GetPassByIndex(0).Apply(); if (model.Mesh != null) { model.Mesh.Setup(view.Device10, view.Content.Acquire<InputLayout>( new Content.VertexStreamLayoutFromEffect { Signature10 = effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature, Layout = model.Mesh.VertexStreamLayout })); model.Mesh.Draw(device); } }
private static Effect makeEffect(string effectName, EffectType2 type) { Effect effect = new Effect() {Name = effectName}; effect.Type = type; switch (effect.Type) { case EffectType2.Highlight: effect.Properties.Add(new EffectProperty() {Name = "Radius", Value = 5, Type = EffectPropertyType.Number}); effect.Properties.Add(new EffectProperty() {Name = "Color", Value = "#242444", Type = EffectPropertyType.Color}); effect.Properties.Add(new EffectProperty() {Name = "Opacity", Value = 0.5, Type = EffectPropertyType.Number}); effect.Properties.Add(new EffectProperty() {Name = "Rotate", Value = 0, Type = EffectPropertyType.Number}); effect.Properties.Add(new EffectProperty() {Name = "OffsetX", Value = 0, Type = EffectPropertyType.Number}); effect.Properties.Add(new EffectProperty() {Name = "OffsetY", Value = 0, Type = EffectPropertyType.Number}); break; case EffectType2.Rotate: effect.Properties.Add(new EffectProperty() {Name = "Degrees", Value = 90, Type = EffectPropertyType.Number}); break; case EffectType2.Bend: effect.Properties.Add(new EffectProperty() {Name = "Degrees", Value = 15, Type = EffectPropertyType.Number}); break; case EffectType2.StyleProperty: effect.Properties.Add(new EffectProperty() {Name = "Property Name", Value = "background-color", Type = EffectPropertyType.Text}); effect.Properties.Add(new EffectProperty() {Name = "Property Value", Value = "red", Type = EffectPropertyType.Text}); break; case EffectType2.Animated: effect.Properties.Add(new EffectProperty() {Name = "idk", Value = "rite?", Type = EffectPropertyType.Text}); break; } return effect; }
public DrawBatch(Device device, Effect effect, IEnumerable<VertexBufferBinding> vertexBuffers, InputLayout inputLayout, int vertexCount, int baseVertex) : base(device, effect, vertexBuffers, inputLayout) { VertexCount = vertexCount; BaseVertex = baseVertex; }
protected override void LoadContent() { // Loads the effect metaTunnelEffect = Content.Load<Effect>("metatunnel.fxo"); base.LoadContent(); }
/// <summary> /// Initializes a new instance of the <see cref="DXShader"/> class. /// </summary> /// <param name="title">The title.</param> /// <param name="filename">The filename.</param> /// <param name="myDevice">My device.</param> /// <remarks></remarks> public DXShader(string title, string filename, ref Device myDevice) { myTitle = title; myFile = filename; string error = string.Empty; myEffect = Effect.FromFile(myDevice, filename, null, null, ShaderFlags.PartialPrecision, null, out error); }
public override void LoadResources() { string base_path = (string)settings["Base.Path"]; // load effect string errors; effect = Effect.FromFile(device, base_path + "Media/Effects/noise.fx", null, null, ShaderFlags.NotCloneable, null, out errors); if (errors.Length > 0) throw new Exception("HLSL compile error"); string temp = null; FindAnnotationString(effect, "permTexture", "function", ref temp); EffectHandle function = effect.GetFunction(temp); FindAnnotationString(effect, "permTexture", "width", ref temp); int width = Int32.Parse(temp); FindAnnotationString(effect, "permTexture", "height", ref temp); int height = Int32.Parse(temp); // generate textures Surface surface = device.GetRenderTarget(0); GenerateTexture(ref permTexture, width, height, function); device.SetRenderTarget(0, surface); }
// Use this for initialization public void StartMe() { /* * Don't let them get goggles if they already have goggles or if they're the scout. */ if (Player.MyPlayer.GetComponent<Player>().GetStatValue(Stat.VISION) == 3 || Player.MyPlayer.GetComponent<Player>().GetPlayerClassObject().GetClassTypeEnum() == Classes.SCOUT) { Destroy(this); return; } Log(); ObjectiveName = "AlienSecondaryTwo"; Title = "Steal Goggles"; Description = "Steal the night vision goggles.\n" + "REWARD: extra vision." + StringMethodsScript.NEWLINE; GameObject objective = PickAlienObjective(); Location = Tile.TilePosition(objective.transform.position); interactable = objective.AddComponent<AlienSecondaryTwoInteractable>(); interactable.InstantInteract = true; interactable.StartMe(); visionEffect = new StatusTurnEffect(Stat.VISION, 3.0, 1, "Dimmed Lights: Vision Increased", "Icons/Effects/alienvisionpurple", -1, true); }
public void Reload() { if (fileName != null) { this.dxEffect = ResourceCache.Instance.GetDxEffect(fileName); } }
public void UpdatedUsedParameters(Effect effect, ParameterCollection parameters) { // Try to update counters only if possible var internalValues = parameters.InternalValues; bool parameterKeyMatches = SortedCounters.Length == internalValues.Count; if (parameterKeyMatches) { for (int i = 0; i < internalValues.Count; ++i) { if (SortedKeys[i] != internalValues[i].Key) { parameterKeyMatches = false; break; } SortedCounters[i] = internalValues[i].Value.Counter; } } // Somehow, the used parameters changed, we need a full reset if (!parameterKeyMatches) { Initialize(effect, parameters); } }
public virtual void applyToEffect(Effect effect) { effect.SetValue("lightColor", ColorValue.FromColor(this.color)); effect.SetValue("lightPosition", TgcParserUtils.vector3ToFloat4Array(this.position)); effect.SetValue("lightIntensity", this.intensity); effect.SetValue("lightAttenuation", this.attenuation); }
public override void Setup(Game _game, UserInput _keyboard, ScreenMessage _message) { base.Setup(_game, _keyboard, _message); Sprite title = new Sprite(new Bitmap("pictures/title.png")); title.Position = new Vector2f(); title.Size = new Vector2f(Game.Width, Game.Height); m_house.AddDrawable(title); Text text = new Text("[Click] or Press [Space] to Start"); text.CentreOn(new Vector2f(Game.Width/2, Game.Height/5)); m_house.AddDrawable(text); fx_buffer = new Effect( new Vector2i(Game.ScreenWidth, Game.ScreenHeight), new Vector2i(Game.ScreenWidth, Game.ScreenHeight), new Vector2i(Game.Width, Game.Height)) { CaptureLayer = Layer.Normal, Layer = Layer.FX, Priority = Priority.Front }; fx_buffer.SetHUD(_game.Camera); fx_buffer.SetFading(0.5f, new Colour(0,0,0,1), new Colour(0,0,0,0)); m_house.AddDrawable(fx_buffer); m_house.AddUpdateable(fx_buffer); }
public void Initialize(Device device, Effect effect) { this.device = device; this.effect = effect; image = ImageConverter.GetNullTexture(device); Update(); }
public override void LoadResources() { string base_path = (string)settings["Base.Path"]; // load effect string errors; effect = Effect.FromFile(device, base_path + "Media/Effects/Bloom-new.fx", null, null, ShaderFlags.None, null, out errors); if (errors.Length > 0) throw new Exception("HLSL compile error"); brightPass = effect.GetTechnique("std_BloomBrightPass"); blurPass = effect.GetTechnique("std_BlurPass"); finalPass = effect.GetTechnique("std_FinalPass"); bpQuad = new CustomVertex.TransformedTextured[4]; bpQuad[0].Tu = 0; bpQuad[0].Tv = 0; bpQuad[1].Tu = 1; bpQuad[1].Tv = 0; bpQuad[2].Tu = 0; bpQuad[2].Tv = 1; bpQuad[3].Tu = 1; bpQuad[3].Tv = 1; //testTexture = TextureLoader.FromFile(device, "c:/blurTest.bmp", 256, 128, 0, Usage.None, Format.X8R8G8B8, Pool.Managed, Filter.None, Filter.None, 0); }
// Use this for initialization void Start() { Effect e = new Effect (transform.position, lightningStrike, 0.5f); e = new Effect (transform.position + Vector3.down*smokeHeight, smoke, 5); e = new Effect (transform.position, sound, 3); e = new Effect (new Vector3(0,0,0), background, 0.5f); }
private void Initialize(Effect effect, ParameterCollection usedParameters) { if (effect == null) throw new ArgumentNullException("effect"); // TODO: Should we ignore various compiler keys such as CompilerParameters.GraphicsPlatformKey, CompilerParameters.GraphicsProfileKey and CompilerParameters.DebugKey? // That was done previously in Effect.CompilerParameters // TODO: Should we clone usedParameters? Or somehow make sure it is immutable? (for now it uses the one straight from EffectCompiler, which might not be a good idea...) Parameters = usedParameters; var parameters = usedParameters; var internalValues = parameters.InternalValues; SortedKeys = new ParameterKey[internalValues.Count]; SortedKeyHashes = new ulong[internalValues.Count]; SortedCompilationValues = new object[internalValues.Count]; SortedCounters = new int[internalValues.Count]; for (int i = 0; i < internalValues.Count; ++i) { var internalValue = internalValues[i]; SortedKeys[i] = internalValue.Key; SortedKeyHashes[i] = internalValue.Key.HashCode; SortedCompilationValues[i] = internalValue.Value.Object; SortedCounters[i] = internalValue.Value.Counter; } var keyMapping = new Dictionary<ParameterKey, int>(); for (int i = 0; i < SortedKeys.Length; i++) keyMapping.Add(SortedKeys[i], i); Parameters.SetKeyMapping(keyMapping); }
void Awake() { var effect = GetComponent<Effect>(); if (effect != null) { this.effect = effect; } }
//Constructor public Tower(int x, int z, Effect.EffectType effect, bool pastState, int direction, int eEntry) { towerXPos = x; towerZPos = z; this.effect = new Effect (effect); direct = direction; Debug.Log (direction + " " + eEntry); enemyEntry = eEntry; //direct = dir; active = true; animHelper = 0; /*towerObj = GameObject.CreatePrimitive(PrimitiveType.Cube); towerObj.renderer.enabled = true; towerObj.transform.position = new Vector3(towerXPos, 0, towerZPos); towerObj.transform.localScale = new Vector3(1f,0.5f,1f); towerObj.transform.Rotate(0,0,180); towerObj.transform.tag = "tower";*/ // New Model Initialization GameObject towerPrefab = PrefabFactory.GetTowerPrefab(); GameManager.InstantiateModel(towerPrefab, new Vector3(x,0,z)); towerObj = GameObject.Find("TowerPrefab(Clone)"); towerObj.transform.tag = "tower"; crystal = towerObj.transform.Find("Sphere").gameObject; upperRing = towerObj.transform.Find("UpperRing").gameObject; lowerRing = towerObj.transform.Find("LowerRing").gameObject; this.pastState = pastState; if (effect == Effect.EffectType.Fire){ towerName = "Single Fire Tower ["+x+","+z+"]"; if (pastState == true){ //SetTextureTower(TextureFactory.GetFireTowerPast()); towerObj.name = towerName; //+ " (Past)"; } else { //SetTextureTower(TextureFactory.GetFireTowerFuture()); towerObj.name = towerName; //+ " (Future)"; SetTowerObjColor(ColorFactory.GetLightRed()); } } if (effect == Effect.EffectType.Ice){ towerName = "Area of Effect Tower ["+x+","+z+"]"; if (pastState == true){ //SetTextureTower(TextureFactory.GetIceTowerPast()); towerObj.name = towerName; //+ " (Past)"; } else { //SetTextureTower(TextureFactory.GetIceTowerFuture()); towerObj.name = towerName; //+ " (Future)"; SetTowerObjColor(ColorFactory.GetLightBlue()); } } CreateZone(); }
void IEffectControlProvider.RegisterEffect(Effect effect) { VisualElementRenderer <VisualElement> .RegisterEffect(effect, NativeView); }
public static void Show(string OSname, Effect efx, ConsoleColor color, int ms_sleep = 20) { if (ms_sleep % 2 == 1) { ms_sleep++; } switch (efx) { case Effect.SlideFromLeft: for (int i = 0; i < ((Console.WindowWidth / 2) - (OSname.Length / 2)); i++) { Console.Clear(); Console.CursorLeft = i; string fill = ""; for (int x = 0; x < i; x++) { fill += " "; } Console.Write(fill); Console.Write(OSname, color, false, true); Core.PIT.SleepMilliseconds((uint)ms_sleep); } break; case Effect.SlideFromRight: for (int i = (Console.WindowWidth - OSname.Length); i > ((Console.WindowWidth / 2) - (OSname.Length / 2)); i--) { Console.Clear(); Console.CursorLeft = i; Console.Write(OSname, color, false, true); Core.PIT.SleepMilliseconds((uint)ms_sleep); } break; case Effect.SlideFromTop: for (int i = 0; i < (Console.WindowHeight / 2); i++) { Console.Clear(); Console.CursorTop = i; Console.WriteLine(OSname, color, true, false); Core.PIT.SleepMilliseconds((uint)ms_sleep); } break; case Effect.SlideFromBottom: for (int i = (Console.WindowHeight - 1); i > (Console.WindowHeight / 2); i--) { Console.Clear(); Console.CursorTop = i; Console.WriteLine(OSname, color, true, false); Core.PIT.SleepMilliseconds((uint)ms_sleep); } break; case Effect.Typewriter: Console.CursorLeft = ((Console.WindowWidth / 2) - (OSname.Length / 2)); foreach (char chr in OSname) { Console.Write(chr.ToString(), color, false, true); Core.PIT.SleepMilliseconds((uint)ms_sleep); } break; case Effect.Matrix: int sec1 = RTC.Now.Second; int sec2 = sec1; do { sec2 = RTC.Now.Second; } while (sec1 == sec2); int sec3; if (sec2 <= 56) { sec3 = sec2 + 3; } else if (sec2 == 57) { sec3 = 1; } else if (sec2 == 58) { sec3 = 2; } else if (sec2 == 59) { sec3 = 3; } else { sec3 = 3; } int tmr = 0; int tmrx = 0; for (int i = 0; i < 10; i++) { for (int ih = 0; ih < Console.WindowHeight; ih++) { for (int iw = 0; iw < Console.WindowWidth; iw++) { if (tmr == 11) { tmr = 0; } if (tmrx == 4) { tmrx = 0; } tmr++; if (tmr == 0) { Console.Write("#", ConsoleColor.Magenta); } if (tmrx == 3) { Console.Write("*", ConsoleColor.Green); } if (tmr == 2) { Console.Write(";", ConsoleColor.Red); ++tmrx; } if (tmrx == 1) { Console.Write("+", ConsoleColor.Yellow); } if (tmr == 4) { Console.Write("~", ConsoleColor.Blue); ++tmrx; } if (tmrx == 2) { Console.Write("&", ConsoleColor.Cyan); } Console.Write(OSname, ConsoleColor.White, true, true); } } } break; } }
public SceneControl(ScreenComponent manager, string style = "") : base(manager, style) { Mask = (int)Math.Pow(2, VIEWRANGE) - 1; Span = (int)Math.Pow(2, VIEWRANGE); SpanOver2 = Span >> 1; player = manager.Player; camera = manager.Camera; assets = manager.Game.Assets; entities = manager.Game.Entity; Manager = manager; simpleShader = manager.Game.Content.Load <Effect>("simple"); sunTexture = assets.LoadTexture(typeof(ScreenComponent), "sun"); //List<Bitmap> bitmaps = new List<Bitmap>(); var definitions = Manager.Game.DefinitionManager.GetBlockDefinitions(); int textureCount = 0; foreach (var definition in definitions) { textureCount += definition.Textures.Length; } int bitmapSize = 128; blockTextures = new Texture2DArray(manager.GraphicsDevice, 1, bitmapSize, bitmapSize, textureCount); int layer = 0; foreach (var definition in definitions) { foreach (var bitmap in definition.Textures) { System.Drawing.Bitmap texture = manager.Game.Assets.LoadBitmap(definition.GetType(), bitmap); var scaled = texture;//new Bitmap(bitmap, new System.Drawing.Size(bitmapSize, bitmapSize)); int[] data = new int[scaled.Width * scaled.Height]; var bitmapData = scaled.LockBits(new System.Drawing.Rectangle(0, 0, scaled.Width, scaled.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); System.Runtime.InteropServices.Marshal.Copy(bitmapData.Scan0, data, 0, data.Length); blockTextures.SetData(data, layer); scaled.UnlockBits(bitmapData); layer++; } } planet = Manager.Game.ResourceManager.GetPlanet(player.Position.Position.Planet); // TODO: evtl. Cache-Size (Dimensions) VIEWRANGE + 1 int range = ((int)Math.Pow(2, VIEWRANGE) - 2) / 2; localChunkCache = new LocalChunkCache(planet.GlobalChunkCache, VIEWRANGE, range); chunkRenderer = new ChunkRenderer[ (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE), planet.Size.Z]; orderedChunkRenderer = new List <ChunkRenderer>( (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE) * planet.Size.Z); for (int i = 0; i < chunkRenderer.GetLength(0); i++) { for (int j = 0; j < chunkRenderer.GetLength(1); j++) { ChunkRenderer renderer = new ChunkRenderer(this, Manager.Game.DefinitionManager, simpleShader, manager.GraphicsDevice, camera.Projection, blockTextures); chunkRenderer[i, j] = renderer; orderedChunkRenderer.Add(renderer); } } backgroundThread = new Thread(BackgroundLoop) { Priority = ThreadPriority.Lowest, IsBackground = true }; backgroundThread.Start(); backgroundThread2 = new Thread(ForceUpdateBackgroundLoop) { Priority = ThreadPriority.Lowest, IsBackground = true }; backgroundThread2.Start(); var additional = Environment.ProcessorCount / 3; additional = additional == 0 ? 1 : additional; _fillIncrement = additional + 1; additionalFillResetEvents = new AutoResetEvent[additional]; _additionalRegenerationThreads = new Thread[additional]; for (int i = 0; i < additional; i++) { var t = new Thread(AdditionalFillerBackgroundLoop) { Priority = ThreadPriority.Lowest, IsBackground = true }; var are = new AutoResetEvent(false); t.Start(new object[] { are, i }); additionalFillResetEvents[i] = are; _additionalRegenerationThreads[i] = t; } var selectionVertices = new[] { new VertexPositionColor(new Vector3(-0.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, -0.001f), Color.Black * 0.5f), }; var billboardVertices = new[] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0), new Vector2(0, 0)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0), new Vector2(1, 1)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), }; var selectionIndices = new short[] { 0, 1, 0, 2, 1, 3, 2, 3, 4, 5, 4, 6, 5, 7, 6, 7, 0, 4, 1, 5, 2, 6, 3, 7 }; selectionLines = new VertexBuffer(manager.GraphicsDevice, VertexPositionColor.VertexDeclaration, selectionVertices.Length); selectionLines.SetData(selectionVertices); selectionIndexBuffer = new IndexBuffer(manager.GraphicsDevice, DrawElementsType.UnsignedShort, selectionIndices.Length); selectionIndexBuffer.SetData(selectionIndices); billboardVertexbuffer = new VertexBuffer(manager.GraphicsDevice, VertexPositionTexture.VertexDeclaration, billboardVertices.Length); billboardVertexbuffer.SetData(billboardVertices); sunEffect = new BasicEffect(manager.GraphicsDevice) { TextureEnabled = true }; selectionEffect = new BasicEffect(manager.GraphicsDevice) { VertexColorEnabled = true }; MiniMapTexture = new RenderTarget2D(manager.GraphicsDevice, 128, 128, PixelInternalFormat.Rgb8); // , false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents); miniMapProjectionMatrix = Matrix.CreateOrthographic(128, 128, 1, 10000); }
public void SetEffect(Effect effect) { EffekseerNativePINVOKE.EffectRenderer_SetEffect(swigCPtr, Effect.getCPtr(effect)); }
public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory) { //Load the asset effect = factory.GetEffect("contrast", false, true); }
static ScrollingTrailSection() { _basicTrailEffect = Overlay.cm.Load <Effect>("effects\\trail"); }
public _Roof(GraphicsDevice device, Vector3 position, float angle, Texture2D texture, Effect effect, Texture2D snowTexture) { this.device = device; this.world = Matrix.Identity; this.roofColor = Color.SaddleBrown; this.position = position; this.angle = angle; this.texture = texture; this.snowTexture = snowTexture; this.effect = effect; this.verts = new VertexPositionTexture[] { // telhado new VertexPositionTexture(new Vector3(-2.3f, 4, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(2.3f, 4, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4, -3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, 3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(2.3f, 4.3f, 3.3f), new Vector2(0, 0)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, 3.3f), new Vector2(0, 1)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4, -3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, -3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(2.3f, 4.3f, -3.3f), new Vector2(1, 0)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, -3.3f), new Vector2(0, 1)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(2.3f, 4.3f, -3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(2.3f, 4f, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, -3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(-2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4f, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(-2.3f, 4, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(2.3f, 4.3f, 3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4.3f, -3.3f), new Vector2(0, 0)), //v2 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, 3.3f), new Vector2(0, 1)), //v0 new VertexPositionTexture(new Vector3(-2.3f, 4.3f, -3.3f), new Vector2(1, 0)), //v1 new VertexPositionTexture(new Vector3(2.3f, 4.3f, -3.3f), new Vector2(0, 0)), //v2 }; this.buffer = new VertexBuffer(this.device, typeof(VertexPositionTexture), this.verts.Length, BufferUsage.None); this.buffer.SetData <VertexPositionTexture>(this.verts); }
/// <summary> /// Helper for drawing a texture into a rendertarget, using /// a custom shader to apply postprocessing effects. /// </summary> void DrawFullscreenQuad(Texture2D texture, RenderTarget2D renderTarget, Effect effect) { GraphicsDevice.SetRenderTarget(renderTarget); DrawFullscreenQuad(texture, renderTarget.Width, renderTarget.Height, effect); }
void IEffectControlProvider.RegisterEffect(Effect effect) { _effectControlProvider.RegisterEffect(effect); }
/// <summary> /// Helper for drawing a texture into the current rendertarget, /// using a custom shader to apply postprocessing effects. /// </summary> void DrawFullscreenQuad(Texture2D texture, int width, int height, Effect effect) { SpriteBatch.Begin(0, BlendState.Opaque, null, null, null, effect); SpriteBatch.Draw(texture, new Rectangle(0, 0, width, height), Color.White); SpriteBatch.End(); }
private void StartSpritebatch( FloatRect view, GameBlendModes mode = GameBlendModes.None, GameShader shader = null, GameRenderTexture target = null, bool forced = false, RasterizerState rs = null, bool drawImmediate = false ) { var viewsDiff = view.X != mCurrentSpriteView.X || view.Y != mCurrentSpriteView.Y || view.Width != mCurrentSpriteView.Width || view.Height != mCurrentSpriteView.Height; if (mode != mCurrentBlendmode || shader != mCurrentShader || shader != null && shader.ValuesChanged() || target != mCurrentTarget || viewsDiff || forced || drawImmediate || !mSpriteBatchBegan) { if (mSpriteBatchBegan) { mSpriteBatch.End(); } if (target != null) { mGraphicsDevice?.SetRenderTarget((RenderTarget2D)target.GetTexture()); } else { mGraphicsDevice?.SetRenderTarget(mScreenshotRenderTarget); } var blend = mNormalState; Effect useEffect = null; switch (mode) { case GameBlendModes.None: blend = mNormalState; break; case GameBlendModes.Alpha: blend = BlendState.AlphaBlend; break; case GameBlendModes.Multiply: blend = mMultiplyState; break; case GameBlendModes.Add: blend = BlendState.Additive; break; case GameBlendModes.Opaque: blend = BlendState.Opaque; break; case GameBlendModes.Cutout: blend = mCutoutState; break; } if (shader != null) { useEffect = (Effect)shader.GetShader(); shader.ResetChanged(); } mSpriteBatch.Begin( drawImmediate ? SpriteSortMode.Immediate : SpriteSortMode.Deferred, blend, SamplerState.PointClamp, null, rs, useEffect, Matrix.CreateRotationZ(0f) * Matrix.CreateScale(new Vector3(1, 1, 1)) * Matrix.CreateTranslation(-view.X, -view.Y, 0) ); mCurrentSpriteView = view; mCurrentBlendmode = mode; mCurrentShader = shader; mCurrentTarget = target; mSpriteBatchBegan = true; } }
private void DoEffect(Effect effect, GameObject affected) { projectileEffects[(int)effect](affected); }
public override void Load() { sndConfirm = new FMODSound(FMODSystem, "Content/SFX/Confirm.mp3"); sndDeny = new FMODSound(FMODSystem, "Content/SFX/Deny.mp3"); sndSelection = new FMODSound(FMODSystem, "Content/SFX/Selection.mp3"); sndCancel = new FMODSound(FMODSystem, "Content/SFX/Cancel.mp3"); #region Init outline shader. fxOutline = Content.Load <Effect>("Shaders/Outline"); Matrix Projection = Matrix.CreateOrthographicOffCenter(0, Constants.Width, Constants.Height, 0, 0, -1f); Matrix HalfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); Matrix projectionMatrix = HalfPixelOffset * Projection; fxOutline.Parameters["World"].SetValue(Matrix.Identity); fxOutline.Parameters["View"].SetValue(Matrix.Identity); fxOutline.Parameters["Projection"].SetValue(projectionMatrix); fxOutline.Parameters["TextureOffset"].SetValue(new Vector2(1, 1)); #endregion #region Fonts fntPhaseNumber = Content.Load <SpriteFont>("Battle/Phase/Number"); fntPhaseNumber.Spacing = -5; fntUnitAttack = Content.Load <SpriteFont>("Fonts/Arial16"); fntArial12 = Content.Load <SpriteFont>("Fonts/Arial12"); fntArial10 = Content.Load <SpriteFont>("Fonts/Arial10"); fntArial9 = Content.Load <SpriteFont>("Fonts/Arial9"); fntNumbers = Content.Load <SpriteFont>("Fonts/VFfont"); fntBattleMenuText = Content.Load <SpriteFont>("Fonts/Battle Menu Text"); fntAccuracyNormal = Content.Load <SpriteFont>("Fonts/Accuracy Normal"); fntAccuracySmall = Content.Load <SpriteFont>("Fonts/Accuracy Small"); fntNonDemoDamage = Content.Load <SpriteFont>("Fonts/Battle Damage"); fntNonDemoDamage.Spacing = -5; fntBattleNumberSmall = Content.Load <SpriteFont>("Fonts/Battle Numbers Small"); fntBattleNumberSmall.Spacing = -3; #endregion StatusMenu = new StatusMenuScreen(this); AttackPicker.Load(); fntFinlanderFont = Content.Load <SpriteFont>("Fonts/Finlander Font"); fxGrayscale = Content.Load <Effect>("Shaders/Grayscale"); sprEllipse = Content.Load <Texture2D>("Ellipse"); sprCursor = Content.Load <Texture2D>("Battle/Reticle"); sprUnitHover = Content.Load <Texture2D>("Units/Unit Hover"); sprPhaseBackground = Content.Load <Texture2D>("Battle/Phase/Background"); sprPhasePlayer = Content.Load <Texture2D>("Battle/Phase/Player"); sprPhaseEnemy = Content.Load <Texture2D>("Battle/Phase/Enemy"); sprPhaseTurn = Content.Load <Texture2D>("Battle/Phase/Turn"); LoadMapScripts(); LoadEffects(); LoadAutomaticSkillActivation(); LoadManualSkillActivation(); LoadSkillRequirements(); LoadScripts(); LoadUnits(); sprCursorTerrainSelection = Content.Load <Texture2D>("Battle/Cursor/Terrain Selection"); #region Bars sprBarSmallBackground = Content.Load <Texture2D>("Battle/Bars/Small Bar"); sprBarSmallEN = Content.Load <Texture2D>("Battle/Bars/Small Energy"); sprBarSmallHP = Content.Load <Texture2D>("Battle/Bars/Small Health"); sprBarLargeBackground = Content.Load <Texture2D>("Battle/Bars/Large Bar"); sprBarLargeEN = Content.Load <Texture2D>("Battle/Bars/Large Energy"); sprBarLargeHP = Content.Load <Texture2D>("Battle/Bars/Large Health"); sprBarExtraLargeBackground = Content.Load <Texture2D>("Battle/Bars/Extra Long Bar"); sprBarExtraLargeEN = Content.Load <Texture2D>("Battle/Bars/Extra Long Energy"); sprBarExtraLargeHP = Content.Load <Texture2D>("Battle/Bars/Extra Long Health"); #endregion }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); form2 = new Form2(); form2.savePosMap.Click += savePosMap_Click; form2.Show(); if ( Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, new[] { FeatureLevel.Level_11_0 }, new SwapChainDescription() { BufferCount = 2, Flags = SwapChainFlags.AllowModeSwitch, IsWindowed = true, ModeDescription = new ModeDescription() { Format = Format.R8G8B8A8_UNorm, Height = Height, RefreshRate = new Rational(1, 60), Scaling = DisplayModeScaling.Stretched, ScanlineOrdering = DisplayModeScanlineOrdering.Progressive, Width = Width }, OutputHandle = Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }, out device, out swapChain).IsSuccess) { Vector4[] verticies = new Vector4[] { new Vector4(-1, 1, 0.5f, 1), new Vector4(1, 1, 0.5f, 1), new Vector4(-1, -1, 0.5f, 1), new Vector4(1, 1, 0.5f, 1), new Vector4(1, -1, 0.5f, 1), new Vector4(-1, -1, 0.5f, 1), }; List <Vector4> translated = new List <Vector4>(); int itr = 200; float edgeLength = 2.0f / itr; Matrix scaling = Matrix.Scaling(new Vector3(edgeLength)); Matrix toVertex = Matrix.Translation(edgeLength / 2f - 1.0f, edgeLength / 2f - 1.0f, 0); for (int ix = 0; ix < itr; ix++) { for (int iy = 0; iy < itr; iy++) { foreach (var vertex in verticies) { translated.Add(Vector4.Transform(vertex, scaling * toVertex * Matrix.Translation(ix * edgeLength, iy * edgeLength, 0))); } } } this.verticies = verticies = translated.ToArray(); using (DataStream ds = new DataStream(verticies, true, true)) { vertexBuffer = new Buffer(device, ds, new BufferDescription((int)ds.Length, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 16)); } using (ShaderBytecode sb = ShaderBytecode.CompileFromFile("shader.fx", "fx_5_0")) { effect = new Effect(device, sb); inputLayout = new InputLayout(device, effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature, new InputElement[] { new InputElement() { SemanticName = "POSITION", Format = Format.R32G32B32A32_Float }, }); } using (Texture2D tex = SlimDX.Direct3D11.Resource.FromSwapChain <Texture2D>(swapChain, 0)) { renderTarget = new RenderTargetView(device, tex); } posOuttexture = new Texture2D(device, new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.RenderTarget, CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8G8B8A8_UNorm, Height = Height, Width = Width, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default }); this.posOutTarget = new RenderTargetView(device, posOuttexture); gradOutTargetTexture = new Texture2D(device, new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.RenderTarget, CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8G8B8A8_UNorm, Height = Height, Width = Width, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default }); gradOutTarget = new RenderTargetView(device, gradOutTargetTexture); device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer, 16, 0) }); device.ImmediateContext.OutputMerger.SetTargets(renderTarget, posOutTarget, gradOutTarget); device.ImmediateContext.InputAssembler.InputLayout = inputLayout; device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; device.ImmediateContext.Rasterizer.SetViewports(new Viewport(0, 0, Width, Height, 0, 1)); device.ImmediateContext.Rasterizer.State = RasterizerState.FromDescription(device, new RasterizerStateDescription() { CullMode = CullMode.None, FillMode = FillMode.Solid }); } else { throw new Direct3D11Exception("Failed to initialize device and swapchain"); } }
public CardEffect(CardComponent card, Effect effect, EffectType type, string name = null, int actionCost = 0, int resourceCost = 0, bool needExhaust = false, InvestigatorComponent investigatorImageCardInfoOwner = null, InvestigatorComponent investigatorRealOwner = null, Effect payEffect = null, Effect cancelEffect = null, Effect animationEffect = null, Func <bool> checkFilterToCancel = null) { Card = card; Effect = effect; PayCostEffect = payEffect; CancelEffect = cancelEffect; Type = type; Name = name; ActionCost = actionCost; ResourceCost = resourceCost; NeedExhaust = needExhaust; AnimationEffect = animationEffect; PlayOwner = investigatorImageCardInfoOwner ?? GameControl.ActiveInvestigator ?? GameControl.LeadInvestigator; RealVisualOwner = investigatorRealOwner ?? (PlayOwner != card.VisualOwner ? card.VisualOwner : null); CheckFilterToCancel = checkFilterToCancel; }
/// <summary> /// Initializes force feedback. /// </summary> /// <param name="device">The device representing the joystick.</param> /// <param name="xAxisOffset">The id of the x axis-providing device.</param> /// <param name="yAxisOffset">The id of the y axis-providing device.</param> /// <param name="numAxes">The number of axes supported by the device. If set to 1, an x-axis is assumed; if anything else, an x and y-axis is assumed.</param> /// <returns>True if force feedback was initialized, false otherwise.</returns> public static bool dInputInitFD(Device device, int xAxisOffset, int yAxisOffset, int numAxes) { try { Guid forceFeedbackGuid = Guid.Empty; forceFeedbackGuid = EffectGuid.ConstantForce; int[] offsets = null; int[] coords = null; if (numAxes == 1) { offsets = new int[1]; offsets[0] = xAxisOffset; coords = new int[1]; } else { offsets = new int[2]; offsets[0] = xAxisOffset; offsets[1] = yAxisOffset; coords = new int[2]; } //offsets[0] = 4; //offsets[1] = 0; for (int i = 0; i < coords.Length; i++) { coords[i] = 0; } EffectParameters info = new EffectParameters(); info.Flags = EffectFlags.Polar | EffectFlags.ObjectIds; ConstantForce typeSpec = new ConstantForce(); typeSpec.Magnitude = 5000; info.Duration = -1; info.SamplePeriod = 0; info.Parameters = typeSpec; info.TriggerButton = -1; info.TriggerRepeatInterval = 0; info.Gain = 5000; info.SetAxes(offsets, coords); info.StartDelay = 0; Envelope env = new Envelope(); env.AttackLevel = 10000; env.AttackTime = 0; env.FadeLevel = 10000; env.FadeTime = 0; info.Envelope = null; afterburnerEffect = new Effect(device, EffectGuid.ConstantForce, info); ConstantForce gFTypeSpec = new ConstantForce(); gFTypeSpec.Magnitude = 3000; info = new EffectParameters(); info.SamplePeriod = 0; info.Parameters = gFTypeSpec; info.TriggerButton = -1; info.TriggerRepeatInterval = -1; info.Gain = 3000; info.Flags = EffectFlags.Polar | EffectFlags.ObjectIds; info.SetAxes(offsets, coords); info.StartDelay = 0; info.Envelope = null; info.Duration = -1; gForceEffect = new Effect(device, EffectGuid.ConstantForce, info); env.AttackLevel = 0; //this is +parameter.magnitude env.AttackTime = 0; env.FadeLevel = 10000; env.FadeTime = 2000000; //How long it will take effect to reach fadeLevel info.Envelope = env; ConstantForce cmType = new ConstantForce(); cmType.Magnitude = 3000; info.Parameters = cmType; info.Duration = 1000000; //at sustained level info.Gain = 3000; cruiseMissileEffect = new Effect(device, EffectGuid.ConstantForce, info); ConstantForce fType = new ConstantForce(); fType.Magnitude = 3000; info.Duration = 50000; info.Gain = 3000; info.Parameters = fType; info.Envelope = null; fireEffect = new Effect(device, EffectGuid.ConstantForce, info); ConstantForce eType = new ConstantForce(); eType.Magnitude = 10000; info.Parameters = eType; info.Gain = 10000; info.Duration = 0; env.AttackTime = 0; env.AttackLevel = 0; env.FadeTime = 7000000; env.FadeLevel = 3000; info.Envelope = env; explodeEffect = new Effect(device, EffectGuid.ConstantForce, info); ConstantForce hType = new ConstantForce(); hType.Magnitude = 3200; info.Parameters = hType; info.Gain = 3200; info.Duration = 100000; info.Envelope = null; hitEffect = new Effect(device, EffectGuid.ConstantForce, info); return(true); } catch { return(false); } }
public bool Execute(params object[] Params) { Habbo Player = (Habbo)Params[0]; if (Player == null) { return(false); } Item Item = (Item)Params[1]; if (Item == null) { return(false); } if (!SetItems.ContainsKey(Item.Id)) { return(false); } ICollection <IWiredItem> Effects = Instance.GetWired().GetEffects(this); ICollection <IWiredItem> Conditions = Instance.GetWired().GetConditions(this); foreach (IWiredItem Condition in Conditions) { if (!Condition.Execute(Player)) { return(false); } if (Instance != null) { Instance.GetWired().OnEvent(Condition.Item); } } //Check the ICollection to find the random addon effect. bool HasRandomEffectAddon = Effects.Count(x => x.Type == WiredBoxType.AddonRandomEffect) > 0; if (HasRandomEffectAddon) { //Okay, so we have a random addon effect, now lets get the IWiredItem and attempt to execute it. IWiredItem RandomBox = Effects.FirstOrDefault(x => x.Type == WiredBoxType.AddonRandomEffect); if (!RandomBox.Execute()) { return(false); } //Success! Let's get our selected box and continue. IWiredItem SelectedBox = Instance.GetWired().GetRandomEffect(Effects.ToList()); if (!SelectedBox.Execute()) { return(false); } //Woo! Almost there captain, now lets broadcast the update to the room instance. if (Instance != null) { Instance.GetWired().OnEvent(RandomBox.Item); Instance.GetWired().OnEvent(SelectedBox.Item); } } else { foreach (IWiredItem Effect in Effects) { if (!Effect.Execute(Player)) { return(false); } if (Instance != null) { Instance.GetWired().OnEvent(Effect.Item); } } } return(true); }
public void CastAbility(Effect effect, Unit unit) { unit.AddEffect(effect); }
/// <summary> /// Creates a new skybox /// </summary> /// <param name="skyboxTexture">the name of the skybox texture to use</param> public Skybox(string skyboxTexture, ContentManager Content) { skyBox = Content.Load <Model>("Skyboxes/cube"); skyBoxTexture = Content.Load <TextureCube>(skyboxTexture); skyBoxEffect = Content.Load <Effect>("Skyboxes/Skybox"); }
public override void Initialize(Effect parentEffect, LayerMask mask, float life = 0, float damage = 0) { base.Initialize(parentEffect, mask, life, damage); }
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) { }
public T Load <T>(string assetName) { string originalAssetName = assetName; object result = null; if (this.graphicsDeviceService == null) { this.graphicsDeviceService = serviceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; if (this.graphicsDeviceService == null) { throw new InvalidOperationException("No Graphics Device Service"); } } if (string.IsNullOrEmpty(assetName)) { throw new ArgumentException("assetname"); } if (!string.IsNullOrEmpty(_rootDirectory)) { assetName = _rootDirectory + Path.DirectorySeparatorChar + assetName; } // Check for windows-style directory separator character assetName = assetName.Replace('\\', Path.DirectorySeparatorChar); // Get the real file name if ((typeof(T) == typeof(Texture2D))) { assetName = Texture2DReader.Normalize(assetName); } if ((typeof(T) == typeof(SpriteFont))) { assetName = SpriteFontReader.Normalize(assetName); } if ((typeof(T) == typeof(Song))) { assetName = SongReader.Normalize(assetName); } if ((typeof(T) == typeof(SoundEffect))) { assetName = SoundEffectReader.Normalize(assetName); } if ((typeof(T) == typeof(Video))) { assetName = Video.Normalize(assetName); } if ((typeof(T) == typeof(Effect))) { assetName = Effect.Normalize(assetName); } if (string.IsNullOrEmpty(assetName)) { throw new ContentLoadException("Could not load " + originalAssetName + " asset!"); } if (Path.GetExtension(assetName).ToUpper() != ".XNB") { if ((typeof(T) == typeof(Texture2D))) { result = Texture2D.FromFile(graphicsDeviceService.GraphicsDevice, assetName); } if ((typeof(T) == typeof(SpriteFont))) { //result = new SpriteFont(Texture2D.FromFile(graphicsDeviceService.GraphicsDevice,assetName), null, null, null, 0, 0.0f, null, null); throw new NotImplementedException(); } if ((typeof(T) == typeof(Song))) { result = new Song(assetName); } if ((typeof(T) == typeof(SoundEffect))) { result = new SoundEffect(assetName); } if ((typeof(T) == typeof(Video))) { result = new Video(assetName); } } else { // Load a XNB file FileStream stream = new FileStream(assetName, FileMode.Open, FileAccess.Read, FileShare.Read); ContentReader reader = new ContentReader(this, stream, this.graphicsDeviceService.GraphicsDevice); ContentTypeReaderManager typeManager = new ContentTypeReaderManager(reader); reader.TypeReaders = typeManager.LoadAssetReaders(reader); foreach (ContentTypeReader r in reader.TypeReaders) { r.Initialize(typeManager); } // we need to read a byte here for things to work out, not sure why reader.ReadByte(); // Get the 1-based index of the typereader we should use to start decoding with int index = reader.ReadByte(); ContentTypeReader contentReader = reader.TypeReaders[index - 1]; result = reader.ReadObject <T>(contentReader); reader.Close(); stream.Close(); } if (result == null) { throw new ContentLoadException("Could not load " + originalAssetName + " asset!"); } return((T)result); }
public static void NewEffect(IntPtr haptic, ref Effect effect) { GetError(SDL_HapticNewEffect(haptic, ref effect)); }
private void ApplyEffect(Effect effect, GodmaShipEffect godmaEffect, Client forClient = null) { if (godmaEffect.ShouldStart == true) { return; } Ship ship = this.ItemFactory.GetItem <Ship>(this.LocationID); Character character = this.ItemFactory.GetItem <Character>(this.OwnerID); try { // create the environment for this run Node.Dogma.Interpreter.Environment env = new Node.Dogma.Interpreter.Environment() { Character = character, Self = this, Ship = ship, Target = null, Client = forClient }; Opcode opcode = new Interpreter(env).Run(effect.PreExpression.VMCode); if (opcode is OpcodeRunnable runnable) { runnable.Execute(); } else if (opcode is OpcodeWithBooleanOutput booleanOutput) { booleanOutput.Execute(); } else if (opcode is OpcodeWithDoubleOutput doubleOutput) { doubleOutput.Execute(); } } catch (Exception) { // notify the client about it forClient?.NotifyMultiEvent(new OnGodmaShipEffect(godmaEffect)); throw; } // ensure the module is saved this.Persist(); PyDataType duration = 0; if (effect.DurationAttributeID is not null) { duration = this.Attributes[(int)effect.DurationAttributeID]; } // update things like duration, start, etc godmaEffect.StartTime = DateTime.UtcNow.ToFileTimeUtc(); godmaEffect.ShouldStart = true; godmaEffect.Duration = duration; // notify the client about it forClient?.NotifyMultiEvent(new OnGodmaShipEffect(godmaEffect)); if (effect.EffectID == (int)EffectsEnum.Online) { this.ApplyOnlineEffects(forClient); } }
public DayNightFilter(IRenderer renderer, SpriteBatch spriteBatch, GameDate date, Effect averageEffect, Effect colorGradingEffect, List <(float, Texture2D)> _luts)
public static void UpdateEffect(IntPtr haptic, int effect, ref Effect data) { GetError(SDL_HapticUpdateEffect(haptic, effect, ref data)); }
public abstract void DispatchEffect(Effect effect);
static ScrollingTrailSection() { _basicTrailEffect = BlishHud.ActiveContentManager.Load <Effect>("effects\\trail"); }
//draw the box public abstract void Draw(GraphicsDevice device, Effect effect);
/// <summary> /// Computes sample weightings and texture coordinate offsets /// for one pass of a separable gaussian blur filter. /// </summary> public static void SetBloomEffectParameters(Effect gaussianBlurEffect, float dx, float dy, float theta) { // Look up the sample weight and offset effect parameters. EffectParameter weightsParameter, offsetsParameter; weightsParameter = gaussianBlurEffect.Parameters["SampleWeights"]; offsetsParameter = gaussianBlurEffect.Parameters["SampleOffsets"]; // Look up how many samples our gaussian blur effect supports. int sampleCount = weightsParameter.Elements.Count; // Create temporary arrays for computing our filter settings. float[] sampleWeights = new float[sampleCount]; Vector2[] sampleOffsets = new Vector2[sampleCount]; // The first sample always has a zero offset. sampleWeights[0] = ComputeBloomGaussian(0, theta); sampleOffsets[0] = new Vector2(0); // Maintain a sum of all the weighting values. float totalWeights = sampleWeights[0]; // Add pairs of additional sample taps, positioned // along a line in both directions from the center. for (int i = 0; i < sampleCount / 2; i++) { // Store weights for the positive and negative taps. float weight = ComputeBloomGaussian(i + 1, theta); sampleWeights[i * 2 + 1] = weight; sampleWeights[i * 2 + 2] = weight; totalWeights += weight * 2; // To get the maximum amount of blurring from a limited number of // pixel shader samples, we take advantage of the bilinear filtering // hardware inside the texture fetch unit. If we position our texture // coordinates exactly halfway between two texels, the filtering unit // will average them for us, giving two samples for the price of one. // This allows us to step in units of two texels per sample, rather // than just one at a time. The 1.5 offset kicks things off by // positioning us nicely in between two texels. float sampleOffset = i * 2 + 1.5f; Vector2 delta = new Vector2(dx, dy) * sampleOffset; // Store texture coordinate offsets for the positive and negative taps. sampleOffsets[i * 2 + 1] = delta; sampleOffsets[i * 2 + 2] = -delta; } // Normalize the list of sample weightings, so they will always sum to one. for (int i = 0; i < sampleWeights.Length; i++) { sampleWeights[i] /= totalWeights; } // Tell the effect about our new filter settings. weightsParameter.SetValue(sampleWeights); offsetsParameter.SetValue(sampleOffsets); }