示例#1
0
 private static Point?[,] GetClickTargets(BattleItem[,] items)
 {
     var rows = items.GetLength(0);
     var columns = items.GetLength(1);
     var targets = new Point?[rows, columns];
     foreach (var row in Enumerable.Range(0, rows))
     {
         foreach (var column in Enumerable.Range(0, columns))
         {
             var item = items[row, column];
             if (item == null)
                 continue;
             foreach (var rowOffset in Enumerable.Range(0, item.Height))
                 foreach (var columnOffset in Enumerable.Range(0, item.Width))
                     targets[row + rowOffset, column + columnOffset] = new Point { X = column, Y = row };
         }
     }
     return targets;
 }
示例#2
0
 private static Point? GetDropLocation(BattleItem[,] items, int row, int column, BattleItem item)
 {
     var targets = GetClickTargets(items);
     var itemWidth = item.Width;
     var itemHeight = item.Height;
     var width = items.GetLength(1);
     var height = items.GetLength(0);
     foreach (var rowOffset in Enumerable.Range(0, itemHeight))
         foreach (var columnOffset in Enumerable.Range(0, itemWidth))
         {
             var dropRow = row - rowOffset;
             var dropColumn = column - columnOffset;
             if (CanDropHere(targets, dropRow, dropColumn, itemWidth, itemHeight, width, height))
                 return new Point { X = dropColumn, Y = dropRow };
         }
     return null;
 }
示例#3
0
 private static void DrawBattleItems(GraphicsBuffer buffer, BattleItem[,] items, int topRow, int leftColumn)
 {
     foreach (var row in Enumerable.Range(0, items.GetLength(0)))
         foreach (var column in Enumerable.Range(0, items.GetLength(1)))
         {
             var item = items[row, column];
             if (item != null)
                 buffer.DrawItem(topRow + row * 16, leftColumn + column * 16, item.Image);
         }
 }