private bool Init() { if (m_XSize <= 0 || m_ZSize <= 0 || m_TexWidth <= 0 || m_TexHeight <= 0) { return(false); } m_DeltaX = m_XSize / m_TexWidth; m_DeltaZ = m_ZSize / m_TexHeight; m_InvDeltaX = 1.0f / m_DeltaX; m_InvDeltaZ = 1.0f / m_DeltaZ; m_BeginPos = m_CenterPosition - new Vector3(m_XSize * 0.5f, 0, m_ZSize * 0.5f); m_Renderer = new FOWRenderer(effectMaterial, minimapRenderShader, m_CenterPosition, m_XSize, m_ZSize); m_Map = new FOWMap(m_FogMaskType, m_BeginPos, m_XSize, m_ZSize, m_TexWidth, m_TexHeight, m_HeightRange); IFOWMapData md = gameObject.GetComponent <IFOWMapData>(); if (md != null) { m_Map.SetMapData(md); } else { m_Map.SetMapData(new FOWMapData(m_TexHeight, m_TexHeight)); m_Map.GenerateMapData(m_HeightRange); } if (minimapRenderShader != null) { m_GenerateMinimapMask = true; } return(true); }
private bool Init() { m_XSize = m_ZSize = 200; m_TexWidth = m_TexHeight = 120; m_CenterPosition = new Vector3(100, 0.75f, 100); m_HeightRange = 2; m_BlurOffset = 0.005f; effectShader = Resources.Load <Shader> ("FogOfWarEffect"); blurShader = Resources.Load <Shader> ("FogOfWarBlur"); /*if (m_XSize <= 0 || m_ZSize <= 0 || m_TexWidth <= 0 || m_TexHeight <= 0) * return false;*/ if (effectShader == null || !effectShader.isSupported) { return(false); } m_Camera = gameObject.GetComponent <Camera>(); if (m_Camera == null) { return(false); } m_Camera.depthTextureMode |= DepthTextureMode.Depth; m_DeltaX = m_XSize / m_TexWidth; m_DeltaZ = m_ZSize / m_TexHeight; m_BeginPos = m_CenterPosition - new Vector3(m_XSize / 2, 0, m_ZSize / 2); m_Renderer = new FOWRenderer(effectShader, blurShader, m_CenterPosition, m_XSize, m_ZSize, m_FogColor, m_BlurOffset, m_BlurInteration); m_Map = new FOWMap(m_FogMaskType, m_BeginPos, m_XSize, m_ZSize, m_TexWidth, m_TexHeight, m_HeightRange); return(true); }
void OnDestroy() { if (m_Renderer != null) { m_Renderer.Release(); } if (m_Map != null) { m_Map.Release(); } if (m_FieldDatas != null) { m_FieldDatas.Clear(); } m_FieldDatas = null; m_Renderer = null; m_Map = null; instance = null; }
private bool Init() { if (m_XSize <= 0 || m_ZSize <= 0 || m_TexWidth <= 0 || m_TexHeight <= 0) { return(false); } if (effectShader == null || !effectShader.isSupported) { return(false); } m_Camera = gameObject.GetComponent <Camera>(); if (m_Camera == null) { return(false); } m_Camera.depthTextureMode |= DepthTextureMode.Depth; m_DeltaX = m_XSize / m_TexWidth; m_DeltaZ = m_ZSize / m_TexHeight; m_InvDeltaX = 1.0f / m_DeltaX; m_InvDeltaZ = 1.0f / m_DeltaZ; m_BeginPos = m_CenterPosition - new Vector3(m_XSize * 0.5f, 0, m_ZSize * 0.5f); m_Renderer = new FOWRenderer(effectShader, blurShader, minimapRenderShader, m_CenterPosition, m_XSize, m_ZSize, m_FogColor, m_BlurOffset, m_BlurInteration); m_Map = new FOWMap(m_FogMaskType, m_BeginPos, m_XSize, m_ZSize, m_TexWidth, m_TexHeight, m_HeightRange); IFOWMapData md = gameObject.GetComponent <IFOWMapData>(); if (md != null) { m_Map.SetMapData(md); } else { m_Map.SetMapData(new FOWMapData(m_TexWidth, m_TexHeight)); m_Map.GenerateMapData(m_HeightRange); } if (minimapRenderShader != null) { m_GenerateMinimapMask = true; } return(true); }
/// <summary> /// Sets or replaces the active fog renderer /// </summary> public void SetFogRenderer(FOWRenderer fRenderer) { if (fRenderer == null) { throw new ArgumentNullException("fRenderer"); } if (fogRenderer != null) { if (Application.isPlaying) { Destroy(fogRenderer); } else { DestroyImmediate(fogRenderer, false); } } fogRenderer = fRenderer; if (Application.isPlaying) { InitializeRenderer(); } }
private bool Init() { if (m_XSize <= 0 || m_ZSize <= 0 || m_TexWidth <= 0 || m_TexHeight <= 0) { return(false); } if (effectShader == null || !effectShader.isSupported) { return(false); } m_Camera = gameObject.GetComponent <Camera>(); if (m_Camera == null) { return(false); } m_Camera.depthTextureMode |= DepthTextureMode.Depth; m_DeltaX = m_XSize / m_TexWidth; m_DeltaZ = m_ZSize / m_TexHeight; m_BeginPos = m_CenterPosition - new Vector3(m_XSize / 2, 0, m_ZSize / 2); m_Renderer = new FOWRenderer(effectShader, blurShader, m_CenterPosition, m_XSize, m_ZSize, m_FogColor, m_BlurOffset, m_BlurInteration); m_Map = new FOWMap(m_FogMaskType, m_BeginPos, m_XSize, m_ZSize, m_TexWidth, m_TexHeight, m_HeightRange); return(true); }