Beispiel #1
0
        void Illuminate()
        {
            //remove self from all levelNodes.
            foreach (TileNode t in gridElement.tilemapManager.allTileNodes)
            {
                if (t.lightsOnMe.Contains(this))
                {
                    t.lightsOnMe.Remove(this);
                    t.SetBrightness();
                }
            }
            //dont do anything if we are turned off.
            if (!lightOn)
            {
                return;
            }

            var c = new Vector2Int[0];

            switch (gridLightType)
            {
            case GridLightType.Circle:
                c = GridUtility.Circle(position, lightRange);
                break;

            case GridLightType.Arc:
                c = GridUtility.Arc(position, agent.facingDirection, lightRange, 45);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            foreach (Vector2Int p in c)
            {
                TileNode tn = gridElement.tilemapManager.GetTileNode(p);
                if (tn != null)
                {
                    if (gridElement.tilemapManager.LineOfSight(tn.position, position))
                    {
                        if (!tn.lightsOnMe.Contains(this))
                        {
                            tn.lightsOnMe.Add(this);
                            tn.SetBrightness();
                        }
                    }
                }
            }

            gridElement.tilemapManager.UpdateBrightnessDisplay();
        }
Beispiel #2
0
 public void Sound(Vector2Int center, int manhattanRadius)     //0 is dark 1 is light.
 {
     Vector2Int[] c = GridUtility.Circle(center, manhattanRadius);
     foreach (Vector2Int p in c)
     {
         if (GridUtility.ManhattanDistance(p, center) <= manhattanRadius)
         {
             //circle algorithm isnt manhattan algorith, its bresenham. so we trim.
             TileNode tn = GetTileNode(p);
             if (tn != null)
             {
                 tn.SoundFrom(center);
                 tn.dither.Blink(1);
             }
         }
     }
 }