Class FogOfWarGrid2D
The main class of the Fog of War feature. (PRO version only)
Inheritance
Namespace: Edgar.Unity
Assembly: cs.temp.dll.dll
Syntax
public class FogOfWarGrid2D : MonoBehaviour
Remarks
This class has to be placed on the game object with the camera to which should the effect be applied. See online documentation for information on how to use this feature.
Fields
ColorMode
Declaration
public FogOfWarColorMode ColorMode
Field Value
Type | Description |
---|---|
FogOfWarColorMode |
FadeInDuration
How long should it take to reveal a tile in the fadeIn mode (in seconds).
Declaration
public float FadeInDuration
Field Value
Type | Description |
---|---|
System.Single |
FogColor
Color of tiles that are hidden in the fog.
Declaration
public Color FogColor
Field Value
Type | Description |
---|---|
Color |
FogSmoothness
Controls how many possible fog values there are for every pixel.
Declaration
public int FogSmoothness
Field Value
Type | Description |
---|---|
System.Int32 |
InitialFogTransparency
Declaration
public float InitialFogTransparency
Field Value
Type | Description |
---|---|
System.Single |
Mode
Mode of the Fog of War effect. Is is either Wave or FadeIn.
Declaration
public FogOfWarMode Mode
Field Value
Type | Description |
---|---|
FogOfWarMode |
Remarks
Wave - tiles are revealed based on the distance from the player. FadeIn - tiles are revealed uniformly.
Some fields in the inspector are only revealed when a specific mode is used.
RevealCorridors
Whether to reveal nearby tiles of neighboring corridors.
Declaration
public bool RevealCorridors
Field Value
Type | Description |
---|---|
System.Boolean |
RevealCorridorsGradually
Whether to reveal neighboring corridor tiles gradually.
Declaration
public bool RevealCorridorsGradually
Field Value
Type | Description |
---|---|
System.Boolean |
RevealCorridorsTiles
How many tiles of neighboring corridors should be revealed.
Declaration
public int RevealCorridorsTiles
Field Value
Type | Description |
---|---|
System.Int32 |
TileGranularity
Controls into how many pixel chunks is each tile divided.
Declaration
public int TileGranularity
Field Value
Type | Description |
---|---|
System.Int32 |
TransitionMode
Transition mode of the effect.
Declaration
public FogOfWarTransitionMode TransitionMode
Field Value
Type | Description |
---|---|
FogOfWarTransitionMode |
Remarks
The Smooth mode interpolates values between neighboring tiles while the TileBased mode does not.
WaveOrigin
Declaration
public Transform WaveOrigin
Field Value
Type | Description |
---|---|
Transform |
WaveRevealThreshold
How much time should the tile be completely hidden before revealing it (see online docs).
Declaration
public float WaveRevealThreshold
Field Value
Type | Description |
---|---|
System.Single |
WaveSpeed
Speed of the wave (tiles per second) when in Wave mode.
Declaration
public float WaveSpeed
Field Value
Type | Description |
---|---|
System.Single |
Properties
Instance
Declaration
public static FogOfWarGrid2D Instance { get; protected set; }
Property Value
Type | Description |
---|---|
FogOfWarGrid2D |
Methods
Awake()
Declaration
protected void Awake()
GetMaterial(Camera)
Gets the updated material that can be used to apply the image post-processing effect.
Declaration
public Material GetMaterial(Camera camera)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera |
Returns
Type | Description |
---|---|
Material |
Remarks
This method must be called in each frame to get the current fog of war information. This method is usually called internally by the tool so you do not have to call it manually.
GetRevealedRooms()
Gets all the rooms that are currently revealed.
Declaration
public IReadOnlyList<RoomInstanceGrid2D> GetRevealedRooms()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<RoomInstanceGrid2D> |
Remarks
This method might be useful if you want to save the game and then load it later. Call this method when saving the game and then use RevealRooms() when loading the game.
Reload(Boolean)
Reloads the component, taking already revealed rooms and revealing them again.
Declaration
public void Reload(bool revealImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | revealImmediately | Whether to reveal the rooms immediately without any animation. |
RevealRoom(RoomInstanceGrid2D, Nullable<Vector3>, Boolean)
Reveals a given room.
Declaration
public void RevealRoom(RoomInstanceGrid2D room, Vector3? waveOrigin = default(Vector3? ), bool revealImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
RoomInstanceGrid2D | room | Room to be revealed. |
System.Nullable<Vector3> | waveOrigin | Origin of the wave if the WaveMode is used. If provided, it overrides the waveOrigin given to the Setup() method. |
System.Boolean | revealImmediately | Whether to reveal the room immediately without any animation. |
RevealRoomAndNeighbors(RoomInstanceGrid2D, Nullable<Vector3>, Boolean)
Reveals a given room and all its neighboring rooms.
Declaration
public void RevealRoomAndNeighbors(RoomInstanceGrid2D room, Vector3? waveOrigin = default(Vector3? ), bool revealImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
RoomInstanceGrid2D | room | Room to be revealed. |
System.Nullable<Vector3> | waveOrigin | Origin of the wave if the WaveMode is used. If provided, it overrides the waveOrigin given to the Setup() method. |
System.Boolean | revealImmediately | Whether to reveal the room immediately without any animation. |
RevealRooms(List<RoomInstanceGrid2D>, Nullable<Vector3>, Boolean)
Reveals given rooms.
Declaration
public void RevealRooms(List<RoomInstanceGrid2D> rooms, Vector3? waveOrigin = default(Vector3? ), bool revealImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<RoomInstanceGrid2D> | rooms | Rooms to be revealed. |
System.Nullable<Vector3> | waveOrigin | Origin of the wave if the WaveMode is used. If provided, it overrides the waveOrigin given to the Setup() method. |
System.Boolean | revealImmediately | Whether to reveal the rooms immediately without any animation. |
Setup(GameObject, Transform)
Setups the component, must be called every time after a level is generated.
Declaration
public void Setup(GameObject generatedLevelRoot, Transform waveOrigin = null)
Parameters
Type | Name | Description |
---|---|---|
GameObject | generatedLevelRoot | Root game object of the generated level. |
Transform | waveOrigin | Origin of the fog reveal animation if the Wave mode is used. |
Remarks
The waveOrigin parameter is optional if the FadeIn mode is used. The waveOrigin parameter is optional if the waveOrigin position is provided when calling one of the RevealRoom methods.