// Use this for initialization void Start() { mapData = new int[mapSize, mapSize]; for (int i = 0; i < mapSize; i++) { for (int j = 0; j < mapSize; j++) { mapData[i, j] = Random.Range(0, 100) < 2?1:0; } } for (int t = 0; t < 2; t++) { for (int i = 0; i < mapSize; i++) { for (int j = 0; j < mapSize; j++) { if (mapData[i, j] == 0) { if (FOWTool.InMap(i + 1, j, mapSize, mapSize) && mapData[i + 1, j] == 1) { mapData[i, j] = Random.Range(0, 100) < 60? 1:0; } else if (FOWTool.InMap(i, j + 1, mapSize, mapSize) && mapData[i, j + 1] == 1) { mapData[i, j] = Random.Range(0, 100) < 60 ? 1 : 0; } } } } } map = new FOWMap(); map.InitMap(mapData); playerPos = new int[] { mapSize / 2, mapSize / 2 }; }
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); }
public void Destroy() { if (m_Map != null) { m_Map.Release(); m_Map = null; } if (m_Fowtexture != null) { m_Fowtexture.Release(); m_Fowtexture = null; } }
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); }
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); }
public void Init(FOWData data = null) { if (data != null) { m_FOWData = data; } if (m_Fowtexture == null || m_Fowtexture.width != texWidth || m_Fowtexture.height != texHeight) { if (m_Fowtexture != null) { Object.DestroyImmediate(m_Fowtexture); m_Fowtexture = null; } m_Fowtexture = new RenderTexture(texWidth, texHeight, 0, RenderTextureFormat.ARGB32); m_Fowtexture.wrapMode = TextureWrapMode.Clamp; m_Fowtexture.filterMode = FilterMode.Bilinear; m_Fowtexture.Create(); } if (m_BlurMaterial == null) { m_BlurMaterial = new Material(Shader.Find("Hidden/FOWBlur")); } // Generate map data if (m_Map == null) { m_Map = new FOWMap(data); } m_TextureTexelSize = new Vector2(1.0f / texWidth, 1.0f / texHeight); }