public override void Init(Transform container, UIPopupManager manager) { base.Init(container, manager); playerControls = FindObjectOfType <PlayerControls>(); waterEffect = GameObject.FindObjectOfType <WaterEffect>(); waterEffectSwitch.Init(waterEffect.Status); verticalAxisSwitch.Init(playerControls.YAxisInverted); }
/// <summary> /// Initializes Screen /// </summary> public override void Initialize() { base.Initialize(); _level = new Level.Level(this.Game, this); _level.Initialize(); this.Water = new WaterEffect(Game, this.ScreenManager.ScreenWidth, this.ScreenManager.ScreenHeight); this.Water.Initialize(); this.TransitionOnTime = TimeSpan.FromSeconds(.5f); this.TransitionOffTime = TimeSpan.FromSeconds(.5f); }
void OnTriggerEnter2D(Collider2D other) { switch (other.gameObject.tag) { case "ball": Ball ball = other.gameObject.GetComponent <Ball>(); // Pickup ball if (ball.onGround && balls.Count < 3) { Pickup(ball); } // Get hit if (ball.flying) { ball.OnBounce(this); if (roundLive) { gameManager.spotLightManager.SetTarget(gameObject); PlayerHit(); } } break; case "water": WaterEffect waterEffect = other.gameObject.GetComponent <WaterEffect>(); if (waterEffect.isElectrocuted) { if (!stunned) { Stun(); } } else { speed = maxSpeed * waterEffect.speedReductionFactor; } break; case "electricity": if (!stunned) { Stun(); } break; } }
private static bool ApplyEffect(WaterEffect effect) { // Must be in the right location. var location = Game1.player.currentLocation; if (location.Name != effect.Location) { return(false); } // Conditions must hold. if (!effect.Conditions.check()) { return(false); } // Handle a missing waterTiles array. if (location.waterTiles == null) { if (effect.Apply) { int mapWidth = location.map.Layers[0]?.LayerWidth ?? 0; int mapHeight = location.map.Layers[0]?.LayerHeight ?? 0; location.waterTiles = new bool[mapWidth, mapHeight]; } else { // If removing, nothing to do since there are none to begin with. return(true); } } // Apply or remove the effect. Rectangle area = effect.adjustArea(location); Monitor.Log($"{(effect.Apply ? "Applying" : "Removing")} water effects in area {area} of location '{location.Name}'.", LogLevel.Trace); for (int x = area.Left; x <= area.Right; ++x) { for (int y = area.Top; y <= area.Bottom; ++y) { location.waterTiles[x, y] = effect.Apply; } } return(true); }
protected virtual void Dispose(bool disposing) { if (!disposing) { return; } if (WaterEffect != null) { WaterEffect.Dispose(); WaterEffect = null; } if (basicEffect != null) { basicEffect.Dispose(); basicEffect = null; } }
private void EnableScreenWater(bool isOn, bool bDisableFirst = true) { if (bDisableFirst) { this.DisableScreenEffect(); } if (isOn) { if (GameLevelManager.IsPostProcessReachQuality(300)) { if (CamerasMgr.MainCameraRoot == null) { return; } this.m_waterEffect = CamerasMgr.MainCameraRoot.get_gameObject().AddMissingComponent <WaterEffect>(); this.m_waterEffect.Initialization(); this.m_waterEffect.set_enabled(true); } } else if (this.m_waterEffect != null) { this.m_waterEffect.set_enabled(false); } }
public void DrawWithWaterEffect(GraphicsDevice GD, Vector3 Position, bool UseID, WaterEffect WEffect, Common.Camera Cam) { WEffect.World = Cam.worldMatrix * Matrix.CreateTranslation(Position) * Matrix.CreateTranslation(offset); WEffect.View = Cam.viewMatrix; WEffect.Projection = Cam.projectionMatrix; if (UseID) { throw new NotImplementedException(); } else { WEffect.InternalEffect.CurrentTechnique = WEffect.InternalEffect.Techniques[0]; WEffect.DiffuseColor = new Vector4(0.192f, 0.192f, 0.192f, 1); //1, 1, 1 by default WEffect.LightSpecularColor = new Vector3(0f); WEffect.SpecularColor = new Vector3(1f); WEffect.SpecularPower = 0.14f; WEffect.LightDirection = new Vector3(1, .71f, 1); WEffect.EmissiveColor = new Vector3(0.125f); } GD.SetVertexBuffer(VertexBuffer); WEffect.InternalEffect.CurrentTechnique = WEffect.InternalEffect.Techniques[0]; foreach (EffectPass pass in WEffect.InternalEffect.CurrentTechnique.Passes) { pass.Apply(); ((Device)GD.Handle).ImmediateContext.GeometryShader.Set(WEffect.GS); ((Device)GD.Handle).ImmediateContext.PixelShader.Set(WEffect.PS); ((Device)GD.Handle).ImmediateContext.VertexShader.Set(WEffect.VS); Buffer[] vsBuffers = WEffect.InternalEffect.ConstantBuffers.Select((a) => a._cbuffer).ToArray(); if (vsBuffers != null) { for (int i = 0; i < vsBuffers.Length; ++i) { ((Device)GD.Handle).ImmediateContext.GeometryShader.SetConstantBuffer(i, vsBuffers[i]); ((Device)GD.Handle).ImmediateContext.VertexShader.SetConstantBuffer(i, vsBuffers[i]); ((Device)GD.Handle).ImmediateContext.PixelShader.SetConstantBuffer(i, vsBuffers[i]); } } else { throw new Exception(); } GD.DrawPrimitives(PrimitiveType.TriangleList, 0, VertexBuffer.VertexCount / 3); ((Device)GD.Handle).ImmediateContext.GeometryShader.Set(null); } GD.SetVertexBuffer(null); GD.Indices = null; }
public BaseDeferredRenderGame() : base() { graphics = new GraphicsDeviceManager(this); graphics.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings); Content.RootDirectory = "Content"; inputHandler = new InputHandlerService(this); assetManager = new AssetManager(this); renderer = new DeferredRender(this); rnd = new Random(DateTime.Now.Millisecond); //ggr = new GeographicGridRegistrationSystem(this, new Vector3(10, 5, 20), new BoundingBox(-Vector3.One * 2f, Vector3.One * 2f)); ppManager = new PostProcessingManager(this); test = new TesterEffect(this); test.Enabled = false; ppManager.AddEffect(test); SSAO = new SSAOEffect(this, .1f, 1f, .5f, 1f); SSAO.Enabled = false; ppManager.AddEffect(SSAO); //stHPe = new STHardPointEffect(this, 25, 30, new Color(48, 89, 122)); stHPe = new STHardPointEffect(this, 25, 30, new Color(41, 77, 107), new Color(.125f, .125f, .125f, 1.0f)); stHPe.Enabled = false; ppManager.AddEffect(stHPe); sun = new SunEffect(this, SunPosition); sun.Enabled = false; ppManager.AddEffect(sun); water = new WaterEffect(this); water.waterHeight = -25f; water.Enabled = false; ppManager.AddEffect(water); dof = new DepthOfFieldEffect(this, 5, 30); dof.Enabled = false; ppManager.AddEffect(dof); bloom = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f); bloom.Enabled = false; ppManager.AddEffect(bloom); haze = new HeatHazeEffect(this, "Textures/bumpmap", false); haze.Enabled = false; ppManager.AddEffect(haze); radialBlur = new RadialBlurEffect(this, 0.009f); radialBlur.Enabled = false; ppManager.AddEffect(radialBlur); ripple = new RippleEffect(this); ripple.Enabled = false; ppManager.AddEffect(ripple); fog = new FogEffect(this, 50, 100, Color.DarkSlateGray); fog.Enabled = false; ppManager.AddEffect(fog); godRays = new CrepuscularRays(this, SunPosition, "Textures/flare", 1500, 1f, .99f, 1f, .15f, .25f); //godRays = new CrepuscularRays(this, SunPosition, "Textures/flare", 1500, 1f, .99f, .1f, 0.12f, .25f); godRays.Enabled = false; ppManager.AddEffect(godRays); }