AOS Fog of War
Loading...
Searching...
No Matches
FischlWorks_FogWar.Shadowcaster.FogField Class Reference

Public Member Functions

void AddColumn (LevelColumn levelColumn)
 
Color[] GetColors (float fogPlaneAlpha)
 
void Reset ()
 

Properties

LevelColumn this[int index] [get, set]
 

Detailed Description

A class that holds visibility data updated based on the FOV.

This class is only instantiated and managed by a single Shadowcaster object,
and the object only lasts per session, unlike the serialized LevelData of csFogWar.
This class also has the GetColors() method, which returns the actual texture data in a 1D Color array format.

Member Function Documentation

◆ AddColumn()

void FischlWorks_FogWar.Shadowcaster.FogField.AddColumn ( LevelColumn  levelColumn)
inline
46 {
47 levelRow.Add(levelColumn);
48 }

Referenced by FischlWorks_FogWar.Shadowcaster.Initialize().

◆ GetColors()

Color[] FischlWorks_FogWar.Shadowcaster.FogField.GetColors ( float  fogPlaneAlpha)
inline
59 {
60 if (colors == null)
61 {
62 colors = new Color[levelRow.Count * levelRow[0].Count()];
63 }
64
65 for (int xIterator = 0; xIterator < levelRow[0].Count(); xIterator++)
66 {
67 for (int yIterator = 0; yIterator < levelRow.Count; yIterator++)
68 {
69 int visibility = (int)levelRow[yIterator][levelRow[0].Count() - 1 - xIterator];
70
71 // The reason that the darker side is the revealed ones is to let users customize fog's color
72 colors[levelRow.Count() * (xIterator + 1) - (yIterator + 1)] =
73 new Color(
74 1 - visibility,
75 1 - visibility,
76 1 - visibility,
77 (1 - visibility) * fogPlaneAlpha);
78 }
79 }
80
81 return colors;
82 }

◆ Reset()

void FischlWorks_FogWar.Shadowcaster.FogField.Reset ( )
inline
51 {
52 foreach (LevelColumn levelColumn in levelRow)
53 {
54 levelColumn.Reset();
55 }
56 }

Referenced by FischlWorks_FogWar.Shadowcaster.ResetTileVisibility().

Property Documentation

◆ this[int index]

LevelColumn FischlWorks_FogWar.Shadowcaster.FogField.this[int index]
getset
85 {
86 get {
87 if (index >= 0 && index < levelRow.Count)
88 {
89 return levelRow[index];
90 }
91 else
92 {
93 Debug.LogErrorFormat("index given in x axis is out of range");
94
95 return null;
96 }
97 }
98 set {
99 if (index >= 0 && index < levelRow.Count)
100 {
101 levelRow[index] = value;
102 }
103 else
104 {
105 Debug.LogErrorFormat("index given in x axis is out of range");
106
107 return;
108 }
109 }
110 }

The documentation for this class was generated from the following file: