Exemple #1
0
		public void LightCells(LiveMap _liveMap, Point _point)
		{
			if (!m_lightManagers.ContainsKey(Radius))
			{
				m_lightManagers.Add(Radius, new LosManager(Radius));
			}
			m_lightManagers[Radius].LightCells(_liveMap, _point, Color);
		}
		public LiveMapBlock(LiveMap _liveMap, Point _liveMapBlockId, int _liveMapBlockIndex)
		{
			m_liveMap = _liveMap;
			LiveMapBlockId = _liveMapBlockId;
			m_liveMapBlockIndex = _liveMapBlockIndex;
			LiveCoords = LiveMapBlockId*Constants.MAP_BLOCK_SIZE;

			foreach (var point in LiveCoords.GetAllBlockPoints())
			{
				m_liveMap.Cells[point.X, point.Y] = new LiveMapCell(this, point);
			}
		}
        public LiveMapBlock(LiveMap _liveMap, Point _liveMapBlockId, int _liveMapBlockIndex)
        {
            m_liveMap           = _liveMap;
            LiveMapBlockId      = _liveMapBlockId;
            m_liveMapBlockIndex = _liveMapBlockIndex;
            LiveCoords          = LiveMapBlockId * Constants.MAP_BLOCK_SIZE;

            foreach (var point in LiveCoords.GetAllBlockPoints())
            {
                m_liveMap.Cells[point.X, point.Y] = new LiveMapCell(this, point);
            }
        }
Exemple #4
0
        public void SetMapCell(MapBlock _mapBlock, Point _inBlockCoords, float _rnd, Point _onLiveMapCoords, LiveMap _liveMap)
        {
            ResetCached();

            Rnd = _rnd;
            m_items.Clear();
            Thing = null;

            InBlockCoords = _inBlockCoords;
            m_mapBlock    = _mapBlock;
            m_seenMask    = ((UInt32)1) << InBlockCoords.X;

            Terrain          = _mapBlock.Map[_inBlockCoords.X, _inBlockCoords.Y];
            TerrainAttribute = TerrainAttribute.GetAttribute(Terrain);

            IsSeenBefore    = (_mapBlock.SeenCells[_inBlockCoords.Y] & m_seenMask) != 0;
            OnLiveMapCoords = _onLiveMapCoords;

            ClearTemp();
        }
		public void LightCells(LiveMap _liveMap, Point _point) { m_lightSource.LightCells(_liveMap, _point); }
Exemple #6
0
		public void LightCells(LiveMap _liveMap, Point _dPoint, FColor _fColor)
		{
			unchecked
			{
				var cvisibles = new FColor[m_inOrder.Length];
				var power = new float[m_inOrder.Length];
				var childVisibility = new float[m_inOrder.Length];

				power[0] = _fColor.A;
				childVisibility[0] = 1;

				cvisibles[0] = new FColor(1f, _fColor);
				for (var index = 1; index < m_inOrder.Length; index++)
				{
					cvisibles[index] = FColor.Empty;
				}
				for (var index = 0; index < m_inOrder.Length; index++)
				{
					var losCell = m_inOrder[index];

                    var powerCoeff = power[index];

					if (powerCoeff < LIGHT_THRESHOLD) continue;

					var myPnt = LiveMap.WrapCellCoords(losCell.Point + _dPoint);

					var liveCell = _liveMap.Cells[myPnt.X, myPnt.Y];

					var color = cvisibles[index].NormalColorOnly;

					var transColor = index == 0 ? FColor.White : liveCell.TransparentColor;
					if (childVisibility[index] > 0)
					{
						liveCell.Lighted = liveCell.Lighted.Screen(color.Multiply(powerCoeff));
						powerCoeff *= transColor.A;
						if (powerCoeff < LIGHT_THRESHOLD) continue;
					}
					else
					{
						powerCoeff *= transColor.A;
						if (powerCoeff < LIGHT_THRESHOLD) continue;
						liveCell.Lighted = liveCell.Lighted.Screen(color.Multiply(powerCoeff));
					}

					var childsColor = color.Multiply(transColor);

					foreach (var pair in losCell.CellIndexes)
					{
						var i = pair.Key;

						power[i] += pair.Value*powerCoeff;
						cvisibles[i].AddColorOnly(childsColor);
						childVisibility[i] = pair.Value*liveCell.Visibility.A;
					}
				}
			}
		}
Exemple #7
0
		public void SetVisibleCelss(LiveMap _liveMap, Point _dPoint, FColor _startFrom)
		{
			unchecked
			{
				var cvisibles = new FColor[m_inOrder.Length];
				var visibles = new float[m_inOrder.Length];

				cvisibles[0] = _startFrom;
				visibles[0] = 1;

				for (var index = 0; index < m_inOrder.Length; index++)
				{
					var visibilityCoeff = visibles[index];

					if (visibilityCoeff < VISIBILITY_THRESHOLD) continue;

					var losCell = m_inOrder[index];
					var myPnt = LiveMap.WrapCellCoords(losCell.Point + _dPoint);

					var liveCell = _liveMap.Cells[myPnt.X, myPnt.Y];
					var transColor = index == 0 ? FColor.White : liveCell.TransparentColor;

					visibilityCoeff = transColor.A*visibilityCoeff;
					var childsColor = cvisibles[index].Multiply(transColor);

					if (visibilityCoeff < VISIBILITY_THRESHOLD) continue;

					foreach (var pair in losCell.CellIndexes)
					{
						visibles[pair.Key] += pair.Value*visibilityCoeff;
						cvisibles[pair.Key] = cvisibles[pair.Key].ScreenColorsOnly(childsColor);
					}
				}
				for (var index = 0; index < m_inOrder.Length; index++)
				{
					var visibilityCoeff = visibles[index];
					var color = cvisibles[index];

					if (visibilityCoeff < VISIBILITY_THRESHOLD) continue;

					var losCell = m_inOrder[index];
					var myPnt = LiveMap.WrapCellCoords(losCell.Point + _dPoint);

					var liveCell = _liveMap.Cells[myPnt.X, myPnt.Y];
					liveCell.Visibility = new FColor(Math.Min(1f, visibilityCoeff), color);
				}
			}
		}
Exemple #8
0
 public void LightCells(LiveMap _liveMap, Point _point)
 {
     throw new NotImplementedException();
 }