本文整理汇总了C#中IEngine.PostMove方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.PostMove方法的具体用法?C# IEngine.PostMove怎么用?C# IEngine.PostMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEngine
的用法示例。
在下文中一共展示了IEngine.PostMove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create(IEngine engine)
{
if (engine == null) return;
Engine = engine;
Field = Engine.Field;
Engine.PlayerSetWall += OnSetWall;
Engine.PlayerMove += UpdatePos;
Engine.PlayerChanged += UpdatePos;
grid.Children.Clear();
grid.ColumnDefinitions.Clear();
grid.RowDefinitions.Clear();
int n = Field.Dimension;
int m = Field.Dimension;
for (int j = 0; j < m - 1; ++j)
{
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(16, GridUnitType.Pixel) });
}
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
for (int i = 0; i < n - 1; ++i)
{
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(16, GridUnitType.Pixel) });
}
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
{
Rectangle r = new Rectangle() { Fill = ((i + j) % 2 == 0) ? Brushes.LightSkyBlue : Brushes.LightSlateGray, Margin = new Thickness(-8) };
grid.Children.Add(SetSell(r, i, j));
#if DEBUG
grid.Children.Add(SetSell(new Label() { Content = (i * n + j).ToString() }, i, j));
#endif
}
for (int i = 0; i < n - 1; ++i)
for (int j = 0; j < m - 1; ++j)
{
int i0 = i;
int j0 = j;
Rectangle r = new Rectangle() { Fill = Brushes.Black, Margin = new Thickness(-1) };
r.MouseLeftButtonDown += (s, e) => Engine.PostSetWall(i0, j0, WallStyle.Horizontal);
r.MouseRightButtonDown += (s, e) => Engine.PostSetWall(i0, j0, WallStyle.Vertical);
Grid.SetRow(r, 1 + 2 * i);
Grid.SetColumn(r, 1 + 2 * j);
grid.Children.Add(r);
}
player1 = new Ellipse() { Fill = Brushes.IndianRed, Stroke = Brushes.Black };
grid.Children.Add(SetSell(player1, Field.Hero1.Y, Field.Hero1.X));
player2 = new Ellipse() { Fill = Brushes.DarkBlue, Stroke = Brushes.Black };
grid.Children.Add(SetSell(player2, Field.Hero2.Y, Field.Hero2.X));
arrowDown = new Rectangle() { Margin = new Thickness(10), Fill = Brushes.Yellow };
arrowRight = new Rectangle() { Margin = new Thickness(10), Fill = Brushes.Yellow };
arrowLeft = new Rectangle() { Margin = new Thickness(10), Fill = Brushes.Yellow };
arrowUp = new Rectangle() { Margin = new Thickness(10), Fill = Brushes.Yellow };
arrowDown.MouseDown += (s, e) => Engine.PostMove(0, +1);
arrowUp.MouseDown += (s, e) => Engine.PostMove(0, -1);
arrowLeft.MouseDown += (s, e) => Engine.PostMove(-1, 0);
arrowRight.MouseDown += (s, e) => Engine.PostMove(+1, 0);
UpdatePos(null, null);
}