Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1.    private void ComputeTargetableCellsRecursively( RoomCell origin, int mvpRemaining )
  2.    {
  3.        if(mvpRemaining <= 0)
  4.            return;
  5.  
  6.        var cachedCellDict = new Dictionary<RoomCell, int>();
  7.  
  8.        for(int i = 0; i < 8; i++)
  9.        {
  10.            var cell = Game.Room.GetNeighbor(origin, i);
  11.  
  12.            if(cell == null || TargetableCells.ContainsKey(cell) || cell.Tile.PassCost == 0 || cell.Actor != null)
  13.                continue;
  14.  
  15.            var cost = cell.Tile.PassCost;
  16.  
  17.            //if(i % 2 != 0)
  18.            //    cost *= Game.DiagonalMovementMultiplier;
  19.  
  20.            if(cost <= mvpRemaining)
  21.            {
  22.                cachedCellDict.Add(cell, cost);
  23.                TargetableCells.Add(cell, cost);
  24.            }
  25.        }
  26.  
  27.        foreach(KeyValuePair<RoomCell, int> kvp in cachedCellDict)
  28.        {
  29.            //Debug.Log(kvp.Key.MapX + "," + kvp.Key.MapY);
  30.            ComputeTargetableCellsRecursively(kvp.Key, mvpRemaining - kvp.Value);
  31.        }
  32.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement