本文整理汇总了C#中Coords.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Coords.Equals方法的具体用法?C# Coords.Equals怎么用?C# Coords.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coords
的用法示例。
在下文中一共展示了Coords.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayXML
internal static void DisplayXML(ListBox ListBox1, ObjectXML table)
{
ListBox1.Items.Clear();
StackPanel panel1 = new StackPanel();
panel1.Orientation = Orientation.Horizontal;
ListBox1.VerticalAlignment = VerticalAlignment.Center;
ListBox1.HorizontalAlignment = HorizontalAlignment.Center;
for (int col = 0; col < table.colNum; col++)
{
Button button = new Button();
Coords coords = new Coords(0, col);
button.Name = "field" + '_' + (col + 1).ToString() + '_' + 0.ToString();
button.DataContext = MainWindow.objectXML.header[coords.GetHashCode()];
button.SetBinding(Button.ContentProperty, new Binding("headerCellHeader"));
button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));
button.Click += EditHeaderClick;
button.Foreground = Brushes.Black;
AlignChange(ref button, coords);
getRes(button);
button.Padding = new Thickness(5, 0, 5, 0);
button.Background = Brushes.LightGray;
button.BorderBrush = Brushes.Black;
if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;
panel1.Children.Add(button);
}
ListBox1.Items.Add(panel1);
for (int row = 1; row < table.rowNum; row++)
{
StackPanel panel = new StackPanel();
panel.Orientation = Orientation.Horizontal;
for (int col = 0; col < table.colNum; col++)
{
Button button = new Button();
Coords coords = new Coords(row, col);
Binding bindParam = new Binding();
bindParam.Source = MainWindow.objectXML.cells[coords.GetHashCode()];
bindParam.Path = new PropertyPath("tabCellParametr");
button.Name = "field" + '_' + (col + 1).ToString() + '_' + row.ToString();
button.SetBinding(Button.ContentProperty,bindParam);
button.DataContext = MainWindow.objectXML.header[new Coords(0, col).GetHashCode()];
button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));
button.Foreground = Brushes.Black;
button.Padding = new Thickness(5, 0, 5, 0);
button.Click += EditCellClick;
getRes(button);
AlignChange(ref button, coords);
button.Background = Brushes.LightGray;
button.BorderBrush = Brushes.Black;
if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;
panel.Children.Add(button);
}
ListBox1.Items.Add(panel);
}
}
示例2: isOnExplosionPath
public bool isOnExplosionPath(Coords coord)
{
//check all live bombs and bomb radius
//if coord is on the explosion path, return true
//otherwise false
foreach (Coords bomb in this.liveBombs) {
LocationData datum = GetLocationData (bomb);
int radius = datum.ExplosionRadius;
bool test = (coord.Equals(bomb) || coord.isCardinalEastOf (bomb, radius) || coord.isCardinalNorthOf (bomb, radius) || coord.isCardinalSouthOf (bomb, radius) || coord.isCardinalWestOf (bomb, radius));
if (test) {
return true;
}
}
return false;
}
示例3: PathTo
/// <summary>
/// Find a path between two tiles (not necessarily only or shortest route!)
/// </summary>
/// <param name="from">Tile to start from</param>
/// <param name="to">Tile to move to </param>
/// <param name="result">List to put result path into</param>
/// <param name="visited">TIles visited on current path (avoid circles)</param>
/// <param name="maxlength">Maximum length of path</param>
public void PathTo(Coords from, Backend.Coords to, out List<Coords> result, ref HashSet<Coords> visited, int maxlength = 20)
{
result = null;
if (visited == null)
{
visited = new HashSet<Coords>();
}
visited.Add(from);
if ((
(from.x >= 0) &&
(to.x >= 0)) &&
(from.y >= 0) &&
(to.y >= 0) &&
(to.x < _width) &&
(from.x < _width) &&
(to.y < _height) &&
(from.y < _height)
&& (maxlength > 0))
{
if (from.Equals(to))
{
result = new List<Coords>();
result.Add(to);
visited.Remove(from);
return;
}
Direction dir = WhichWayIs(to, from, true); // start by direct route
int count = 0;
while (count < 4)
{
Backend.Coords tmp = Map.DirectionTile(from, dir);
if ((this[tmp.x, tmp.y].canEnter) && (!visited.Contains(tmp)))
{
// System.Diagnostics.Debug.WriteLine(indent + "Looking " + dir + " of " + from + " to " + tmp);
PathTo(tmp, to, out result, ref visited, maxlength - 1);
if (result != null)
{
// System.Diagnostics.Debug.WriteLine(indent + " - " + from.x + "/" + from.y);
if (result.Count > 1)
{
if ((Math.Abs(result[1].x - from.x) < 2) && (Math.Abs(result[1].y - from.y) < 2) && (CanMove(result[1], WhichWayIs(result[1], from))))
result[0] = from; // Diagonals preferred
else result.Insert(0, from);
}
else
{
result.Insert(0, from); // Only starting point in list
}
visited.Remove(from);
// System.Diagnostics.Debug.WriteLine(indent + "*" + from.x + "/" + from.y + " leads over " + dir.ToString() + " to " + to.x + " / " + to.y);
return;
}
/* else
{
System.Diagnostics.Debug.WriteLine(indent + from.x + "/" + from.y + " no exit " + dir.ToString() + " to " + to.x + " / " + to.y);
} */
}
/* else
{
if (!visited.Contains(tmp))
{
System.Diagnostics.Debug.WriteLine(indent + dir.ToString() + " of " + from.x + "/" + from.y + " is blocked");
}
} */
dir = NextDirection(dir, true);
count += 1;
}
}
//PathTo(from, to, maxlength - 1);
visited.Remove(from);
return;
}
示例4: getBombOnExplosionPath
public Coords getBombOnExplosionPath(Coords coord)
{
//check all live bombs and bomb radius
//if coord is on the explosion path, return the bomb that's going to explode
//otherwise return null
foreach (Coords bomb in this.liveBombs)
{
LocationData datum = GetLocationData(bomb);
int radius = datum.ExplosionRadius;
bool test = (coord.Equals(bomb) || coord.isCardinalEastOf(bomb, radius) || coord.isCardinalNorthOf(bomb, radius) || coord.isCardinalSouthOf(bomb, radius) || coord.isCardinalWestOf(bomb, radius));
if (test)
{
return bomb;
}
}
return null;
}