/// <summary> /// Reads from the binary file to assign cell data to this current cell. /// </summary> /// <param name="reader"> Binary reader used to read the binary file</param> public void Load(BinaryReader reader, int header) { terrainTypeIndex = reader.ReadByte(); ShaderData.RefreshTerrain(this); elevation = reader.ReadByte(); if (header >= 4) { elevation -= 127; } RefreshPosition(); waterLevel = reader.ReadByte(); urbanLevel = reader.ReadByte(); farmLevel = reader.ReadByte(); plantLevel = reader.ReadByte(); specialIndex = reader.ReadByte(); walled = reader.ReadBoolean(); hasIncomingRiver = reader.ReadBoolean(); incomingRiver = (HexDirection)reader.ReadByte(); hasOutgoingRiver = reader.ReadBoolean(); outgoingRiver = (HexDirection)reader.ReadByte(); for (int i = 0; i < roads.Length; i++) { roads[i] = reader.ReadBoolean(); } IsExplored = header >= 3 ? reader.ReadBoolean() : false; ShaderData.RefreshVisibility(this); }
public void ResetExploration() { if (IsExplored) { IsExplored = false; ShaderData.RefreshVisibility(this); } }
public void ResetVisibility() { if (visibility > 0) { visibility = 0; ShaderData.RefreshVisibility(this); } }
public void IncreaseVisibility() { visibility += 1; if (visibility == 1) { ShaderData.RefreshVisibility(this); } }
public void DecreaseVisibility() { visibility -= 1; if (visibility == 0) { ShaderData.RefreshVisibility(this); } }
public void IncreaseVisibility() { visibility += 1; if (visibility == 1) { IsExplored = true; ShaderData.RefreshVisibility(this); } }
public void IncreaseVisibility() { visibility += 1; if (visibility == 1) { IsExplored = true; // When viewed for the first time gets explored, just always set faster than check to set ShaderData.RefreshVisibility(this); } }
public void DecreaseVisibility() { visibility -= 1; if (visibility <= 0) { ShaderData.RefreshVisibility(this); visibility = 0; // Should never have have fewer than 0 units providing visibility } }
public void Load(BinaryReader reader, int header) { // 按照保存顺序读取整形数据 terrainTypeIndex = reader.ReadByte(); ShaderData.RefreshTerrain(this); elevation = reader.ReadByte() - 127; waterLevel = reader.ReadByte(); urbanLevel = reader.ReadByte(); farmLevel = reader.ReadByte(); plantLevel = reader.ReadByte(); specialIndex = reader.ReadByte(); RefreshPosition(); // 刷新六边形gameobject高度 walled = reader.ReadBoolean(); // 读取流入河流数据 byte incomingRiverData = reader.ReadByte(); if (incomingRiverData >= 128) { hasIncomingRiver = true; incomingRiver = (HexDirection)(incomingRiverData - 128); } else { hasIncomingRiver = false; } // 读取流出河流数据 byte ougoingRiverData = reader.ReadByte(); if (ougoingRiverData >= 128) { hasOutgoingRiver = true; outgoingRiver = (HexDirection)(ougoingRiverData - 128); } else { hasOutgoingRiver = false; } // 道路数据 byte roadFlags = reader.ReadByte(); for (int i = 0; i < roads.Length; i++) { roads[i] = (roadFlags & (1 << i)) != 0; // 1左移i位,然后按位与,提取roadFlags对应位的数据。按位与: 0010 0110 & 0000 0010 = 0000 0010 } //0010 0110 & 0000 1000 = 0000 0000 // 探索状态(是否被探索过)数据 IsExplored = header >= 3 ? reader.ReadBoolean() : false; // 存档版本3以上才有探索状态数据 ShaderData.RefreshVisibility(this); }
public void Load(BinaryReader reader, int header) { terrainTypeIndex = reader.ReadByte(); ShaderData.RefreshTerrain(this); if (header >= 4) { elevation -= 127; } RefreshPosition(); waterLevel = reader.ReadByte(); urbanLevel = reader.ReadByte(); farmLevel = reader.ReadByte(); plantLevel = reader.ReadByte(); specialIndex = reader.ReadByte(); walled = reader.ReadBoolean(); byte riverData = reader.ReadByte(); if (riverData >= 128) { hasIncomingRiver = true; incomingRiver = (HexDirection)(riverData - 128); } else { hasIncomingRiver = false; } riverData = reader.ReadByte(); if (riverData >= 128) { hasOutgoingRiver = true; outgoingRiver = (HexDirection)(riverData - 128); } else { hasOutgoingRiver = false; } int roadFlags = reader.ReadByte(); for (int i = 0; i < roads.Length; i++) { roads[i] = (roadFlags & (1 << i)) != 0; } IsExplored = header >= 3 && reader.ReadBoolean(); ShaderData.RefreshVisibility(this); }
public void Load(BinaryReader reader) { terrainTypeIndex = reader.ReadByte(); ShaderData.RefreshTerrain(this); elevation = reader.ReadByte(); elevation -= 127; RefreshPosition(); waterLevel = reader.ReadByte(); urbanLevel = reader.ReadByte(); farmLevel = reader.ReadByte(); plantLevel = reader.ReadByte(); specialIndex = reader.ReadByte(); walled = reader.ReadBoolean(); // Check if 8th bit is 1 which signals existence of river byte riverData = reader.ReadByte(); if (riverData >= 128) { hasIncomingRiver = true; incomingRiver = (HexDirection)(riverData - 128); // Read direction } else { hasIncomingRiver = false; } // Check if 8th bit is 1 which signals existence of river riverData = reader.ReadByte(); if (riverData >= 128) { hasOutgoingRiver = true; outgoingRiver = (HexDirection)(riverData - 128); } else { hasOutgoingRiver = false; } int roadFlags = reader.ReadByte(); for (int i = 0; i < Roads.Length; i++) { Roads[i] = (roadFlags & (1 << i)) != 0; // If flag set then roads exists } IsExplored = reader.ReadBoolean(); ShaderData.RefreshVisibility(this); }
public void IncreaseVisibility(bool editMode) { visibility += 1; if (visibility == 1) { if (editMode == false) { IsExplored = true; } ShaderData.RefreshVisibility(this); UpdateVision(); } }
public void Load(BinaryReader reader, int header) { terrain.TerrainTypeIndex = reader.ReadByte(); ShaderData.RefreshTerrain(this); terrain.Elevation = reader.ReadByte(); RefreshPosition(); terrain.WaterLevel = reader.ReadByte(); urbanLevel = reader.ReadByte(); farmLevel = reader.ReadByte(); plantLevel = reader.ReadByte(); specialIndex = reader.ReadByte(); walled = reader.ReadBoolean(); byte riverData = reader.ReadByte(); if (riverData >= 128) { terrain.RiverTerrain.HasIncomingRiver = true; terrain.RiverTerrain.IncomingRiver = (HexDirection)(riverData - 128); } else { terrain.RiverTerrain.HasIncomingRiver = false; } riverData = reader.ReadByte(); if (riverData >= 128) { terrain.RiverTerrain.HasOutgoingRiver = true; terrain.RiverTerrain.OutgoingRiver = (HexDirection)(riverData - 128); } else { terrain.RiverTerrain.HasOutgoingRiver = false; } int roadFlags = reader.ReadByte(); for (int i = 0; i < terrain.RoadLength; i++) { bool currentFlag = (roadFlags & (1 << i)) != 0; terrain.SetRoad(i, currentFlag); } if (header >= 3) { IsExplored = reader.ReadBoolean(); } ShaderData.RefreshVisibility(this); }
public void DecreaseVisibility() { visibility -= 1; if (visibility == 0) { ShaderData.RefreshVisibility(this); if (Unit && !Unit.Owned) { Unit.unitRenderer.enabled = IsVisible; } if (Item) { Item.ShowEffect(IsVisible); } } }
public void IncreaseVisibility() { visibility += 1; if (visibility == 1) { IsExplored = true; uiRect.GetChild(1).GetComponent <Image>().enabled = false; ShaderData.RefreshVisibility(this); if (Unit && !Unit.Owned) { Unit.unitRenderer.enabled = IsVisible; } if (Item) { Item.ShowEffect(IsVisible); } } }
public void Load(System.IO.BinaryReader reader) { TerrainTypeIndex = reader.ReadByte(); Elevation = reader.ReadByte(); Elevation -= 127; WaterLevel = reader.ReadByte(); UrbanLevel = reader.ReadByte(); FarmLevel = reader.ReadByte(); PlantLevel = reader.ReadByte(); SpecialIndex = reader.ReadByte(); byte riverData = reader.ReadByte(); HasInComingRiver = riverData >= 128; if (HasInComingRiver) { InComingRive = (HexDirectionEnum)(riverData - 128); } riverData = reader.ReadByte(); HasOutGoingRive = riverData >= 128; if (HasOutGoingRive) { OutGoingRive = (HexDirectionEnum)(riverData - 128); } int roadFlags = reader.ReadByte(); for (int i = 0; i < roads.Length; i++) { roads[i] = (roadFlags & (1 << i)) != 0; } walled = reader.ReadBoolean(); IsExplored = reader.ReadBoolean(); ShaderData.RefreshVisibility(this); }
public void SetExploration(bool value) { IsExplored = value; ShaderData.RefreshVisibility(this); }
public void DecreaseVisibility() { visibility = 0; ShaderData.RefreshVisibility(this); }
public void IncreaseVisibility() { visibility = 1; ShaderData.RefreshVisibility(this); }