本文整理汇总了C#中Grid.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.Add方法的具体用法?C# Grid.Add怎么用?C# Grid.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window
public Window()
: base(1280, 720, GraphicsMode.Default, "XUI Example", GameWindowFlags.Default, DisplayDevice.Default, 4, 0, GraphicsContextFlags.Debug)
{
canvas = new Canvas(1280, 720);
grid = new Grid();
canvasRenderer = new CanvasRenderer(canvas, new XUI.Rendering.OpenGL.Renderer());
canvas.Child = grid;
var rnd = new Random(DateTime.Now.Second);
for(int i = 0; i < 10; i++)
{
var button = new Button();
button.Width = Math.Max(50, rnd.NextDouble() * 400);
button.Height = 80;
button.Background = new ColorBrush() { Color = new Color() { R = 1f, G = 1f, B = 1f, A = 1f } };
button.Margin = new Thickness(1.0, 1.0, 1.0, 1.0);
button.Child = new TextBlock() { Text = "Button " + i };
grid.Add(button);
}
#if DEBUG
OpenTK.Graphics.GraphicsContext.CurrentContext.ErrorChecking = true;
GL.DebugMessageCallback((source, type, id, severity, length, message, userParam) =>
{
var msg = Marshal.PtrToStringAnsi(message, length);
System.Diagnostics.Debug.WriteLine("{0} {1} {2}", severity, type, msg);
}, IntPtr.Zero);
GL.Enable(EnableCap.DebugOutput);
#endif
}
示例2: CommandMove_FacingNorthAndAtTopOfGrid_ThrowsException
public void CommandMove_FacingNorthAndAtTopOfGrid_ThrowsException()
{
// arrange
IGrid grid = new Grid(5,5);
IRobot robot = new Robot(0, 4, OrientationEnum.North, fiveByFiveGrid);
grid.Add(robot);
// act
robot.CommandMove();
}
示例3: CommandMove_FacingEastAndAtFarRightOfGrid_ThrowsException
public void CommandMove_FacingEastAndAtFarRightOfGrid_ThrowsException()
{
// arrange
IGrid grid = new Grid(5, 5);
IRobot robot = new Robot(4, 0, OrientationEnum.East, grid);
grid.Add(robot);
// act
robot.CommandMove();
}
示例4: CommandMove_FacingSouthAndAtBottomOfGrid_ThrowsException
public void CommandMove_FacingSouthAndAtBottomOfGrid_ThrowsException()
{
// arrange
IGrid grid = new Grid(5, 5);
IRobot robot = new Robot(0, 0, OrientationEnum.South, grid);
grid.Add(robot);
// act
robot.CommandMove();
}
示例5: LoadLevel
public static Grid LoadLevel(string filename, out string audiofile, out string textfile)
{
audiofile = "";
textfile = "";
StreamReader reader;
string path = "";
if(Application.isEditor)
path = Path.Combine(Application.dataPath + "/Resources/Levels", filename);
else
path = Path.Combine(Application.dataPath, filename);
try {
reader = new StreamReader(path);
}
catch(Exception) {
Debug.Log("Shit, bro! This file didn't work. Filename was: " + filename);
return null;
}
Debug.Log("Loaded from " + path);
int width = Int32.Parse(reader.ReadLine());
int height = Int32.Parse(reader.ReadLine());
grid = new Grid(width, height);
WinChecker.robotsWin = false;
WinChecker.squareWins = false;
WinChecker.robotLimit = -1;
WinChecker.numRobots = 0;
WinChecker.winCoords = default(Vector2);
string line = reader.ReadLine();
string[] conditions = line.Split(new char[] {' '});
for(int i = 0; i < conditions.Length; i++) {
int type = Int32.Parse(conditions[i++]);
switch(type) {
case 0: // Robot
LevelEditor.robotLimit = conditions[i];
LevelEditor.robotsWin = true;
WinChecker.robotsWin = true;
WinChecker.robotLimit = Int32.Parse(conditions[i]);
break;
case 1: // Wall
WinChecker.squareWins = true;
Vector2 winCoords;
winCoords.x = Int32.Parse(conditions[i++]);
winCoords.y = Int32.Parse(conditions[i]);
WinChecker.winCoords = winCoords;
LevelEditor.squareWins = true;
LevelEditor.winCoords = winCoords.x + ", " + winCoords.y;
grid.grid[(int)winCoords.x, (int)winCoords.y].plane.renderer.material.mainTexture = Resources.Load("Textures/winsquare") as Texture;
grid.grid[(int)winCoords.x, (int)winCoords.y].plane.renderer.material.shader = Shader.Find("Transparent/Diffuse");
grid.grid[(int)winCoords.x, (int)winCoords.y].plane.renderer.material.color = Color.white;
grid.grid[(int)winCoords.x, (int)winCoords.y].plane.name = "Win Square";
break;
}
}
while((line = reader.ReadLine()) != null) {
if(line.StartsWith("#"))
continue;
string[] parts = line.Split(new char[] {' '});
int x = Int32.Parse(parts[0]);
int y = Int32.Parse(parts[1]);
for(int i = 2; i < parts.Length;) {
int type = Int32.Parse(parts[i++]);
switch(type) {
case 0: // Wall
grid.Add(Wall.MakeWall(grid, x, y), x, y);
break;
case 1: // SpikeWall
grid.Add(ParseSpikeWall(x, y, CopyRange(parts, i, 5)), x, y);
i += 5;
break;
case 2: // SpikeFloor
grid.Add(SpikeFloor.MakeSpikeFloor(grid, x, y), x, y);
i += 1;
break;
case 3: // Paint
grid.Add(ParsePaint(x, y, CopyRange(parts, i, 2)), x, y);
i += 2;
break;
case 4: // Conveyor
ParseConveyor(x, y, CopyRange(parts, i, 5));
i += 5;
break;
case 5: // Player
GameObject player = ParsePlayer(x, y, CopyRange(parts, i, 1));
grid.Add(player, x, y);
GameManager.player = player.GetComponent<Player>();
i += 1;
break;
case 6: // Robot
grid.Add(ParseRobot(x, y, CopyRange(parts, i, 11)), x, y);
i += 11;
break;
case 7: // DestructibleWall
grid.Add(ParseDestructibleWall(x, y, CopyRange(parts, i, 2)), x, y);
i += 2;
break;
case 8: // ExplosiveCrate
grid.Add(ParseExplosiveCrate(x, y, CopyRange(parts, i, 3)), x, y);
i += 3;
break;
case 9: // Audio file
audiofile = ParseAudioFile(parts, i);
//.........这里部分代码省略.........