Пример #1
0
        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
0
 public Map(int x, int y)
 {
     for (int i = 0; i <= x; i++)
     {
         for (int j = 0; j <= y; j++)
         {
             Grid.Add(new GridPoint(i, j));
         }
     }
 }
Пример #3
0
        public void BuildGrid()
        {
            var width  = Math.Max(CoordsList.Max(x => x.XStarting), CoordsList.Max(x => x.XEnding)) + 1;
            var height = Math.Max(CoordsList.Max(y => y.YStarting), CoordsList.Max(y => y.YEnding)) + 1;

            for (int y = 0; y < height; y++)
            {
                Grid.Add(new List <int>(new int[width]));
            }
        }
        public void IndexerSetOutOfRangeFromAnotherCollection()
        {
            ColumnDefinitionCollection c1 = new Grid().ColumnDefinitions;
            ColumnDefinition           d  = new ColumnDefinition();

            c1.Add(d);
            ColumnDefinitionCollection c2 = new Grid().ColumnDefinitions;

            c2 [0] = d;
        }
        public void AddToMultipleCollectionsOne2()
        {
            ColumnDefinitionCollection c = new Grid().ColumnDefinitions;
            ColumnDefinition           d = new ColumnDefinition();

            c.Add(d);
            c.Remove(d);
            c = new Grid().ColumnDefinitions;
            c.Add(d);
        }
Пример #6
0
        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();
        }
Пример #7
0
        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();
        }
Пример #8
0
        public static void AddHeader(this Grid grid, UIElement element)
        {
            grid.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });
            int column = grid.ColumnDefinitions.Count - 1;

            grid.Add(element, 0, column);
        }
Пример #9
0
        public void Neighbors_ThreeValidNeighborsAndOneInvalid_TwoNeighbors()
        {
            //Arrange
            var sut       = new Grid();
            var testTileA = new Tile(0, 0);
            var testTileB = new Tile(1, 0);
            var testTileC = new Tile(-1, 0);
            var testTileD = new Tile(2, 0);

            //Act
            sut.Add(testTileA);
            sut.Add(testTileB);
            sut.Add(testTileC);
            sut.Add(testTileD);
            var result = sut.Neighbors(testTileA).Count();

            //Assert
            Assert.Equal(2, result);
        }
Пример #10
0
        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();
        }
Пример #11
0
        public void AddedViewGetsDefaultRowAndColumn()
        {
            var gl   = new Grid();
            var view = new Label();

            gl.Add(view);
            Assert.AreEqual(0, gl.GetRow(view));
            Assert.AreEqual(0, gl.GetColumn(view));
            Assert.AreEqual(1, gl.GetRowSpan(view));
            Assert.AreEqual(1, gl.GetColumnSpan(view));
        }
Пример #12
0
        public void CommandMove_FacingWestAndAtFarLeftOfGrid_ThrowsException()
        {
            // arrange
            IGrid  grid  = new Grid(5, 5);
            IRobot robot = new Robot(0, 0, OrientationEnum.West, grid);

            grid.Add(robot);

            // act
            robot.CommandMove();
        }
Пример #13
0
        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();
        }
Пример #14
0
        public void AddViewRowColumn()
        {
            var grid = new Grid();

            var label = new Label();

            grid.Add(label, 3, 4);

            Assert.AreEqual(3, grid.GetColumn(label));
            Assert.AreEqual(4, grid.GetRow(label));
        }
Пример #15
0
        public void AddViewDefaultColumn()
        {
            var grid = new Grid();

            var label = new Label();

            grid.Add(label, row: 3);

            Assert.AreEqual(0, grid.GetColumn(label));
            Assert.AreEqual(3, grid.GetRow(label));
        }
Пример #16
0
        public void AddedMauiViewGetsDefaultRowAndColumn()
        {
            var gl   = new Grid();
            var view = NSubstitute.Substitute.For <IView>();

            gl.Add(view);
            Assert.AreEqual(0, gl.GetRow(view));
            Assert.AreEqual(0, gl.GetColumn(view));
            Assert.AreEqual(1, gl.GetRowSpan(view));
            Assert.AreEqual(1, gl.GetColumnSpan(view));
        }
Пример #17
0
    void Start()
    {
        Tick.Setup(Time.fixedDeltaTime);

        grid = new Grid(20, 0.75);

        follower = new Node("Follower").AddBehavior(new Pedestrian());
        follower.shape.radius = radius;
        grid.Add(follower.shape);
        follower.shape.CreateView();
    }
Пример #18
0
        protected override void CreateScene()
        {
            FixedCamera2D camera = new FixedCamera2D("Camera");
            EntityManager.Add(camera);

            Button newGameButton = new Button("New Game")
            {
                Text = "Neues Spiel",
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
            };
            newGameButton.SetValue(GridControl.RowProperty, 4);
            newGameButton.SetValue(GridControl.ColumnProperty, 0);
            newGameButton.Click += onNewGameButtonClick;

            Button loadGameButton = new Button("Load Game")
            {
                Text = "Spiel laden",
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                //Margin = new WaveEngine.Framework.UI.Thickness(1),
            };
            loadGameButton.SetValue(GridControl.RowProperty, 6);
            loadGameButton.SetValue(GridControl.ColumnProperty, 0);
            loadGameButton.Click += onLoadGameButtonClick;

            Grid uiGrid = new Grid();
            for (int i = 0; i < 8; i++)
            {
                
                uiGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(i % 2 == 0?newGameButton.Height:newGameButton.Height / 2, GridUnitType.Pixel)});
            }

            uiGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });
            uiGrid.HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center;
            uiGrid.VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center;
            EntityManager.Add(uiGrid);

            uiGrid.Add(newGameButton);
            uiGrid.Add(loadGameButton);
        }
Пример #19
0
        public void Add_ValidTile_IncreasedCount()
        {
            //Arrange
            var sut = new Grid();

            //Act
            sut.Add(new Tile());
            var result = sut.Tiles.Count();

            //Assert
            Assert.Equal(1, result);
        }
Пример #20
0
    void Start()
    {
        var g = new Grid <Foo>(5, 3, Allocator.Persistent);

        g.Add(new Foo {
            Position = 2
        });
        g.Add(new Foo {
            Position = 2.5f
        });
        var r = new NativeList <Grid <Foo> .Result>(Allocator.Persistent);

        g.GetClosest(3.5f, 5, r, 10);
        for (int i = 0; i < r.Length; i++)
        {
            Debug.Log(r[i].Item.Position);
        }

        g.Dispose();
        r.Dispose();
    }
Пример #21
0
        public async Task <T> Show(Grid parent, ICommand onLightDismissCommand = null)
        {
            OnLightDismissedCommand = onLightDismissCommand;

            parent.Add(this, 0, parent.ColumnDefinitions.Count, 0, parent.RowDefinitions.Count);

            var res = await Result;

            parent.Children.Remove(this);

            return(res);
        }
Пример #22
0
    Transform CreatePlace(int x, int z)
    {
        Transform instance = Instantiate(placePrefab);
        float     ro       = HexMetrics.outerRadius;
        float     ri       = HexMetrics.innerRadius;
        Vector2   pos      = new Vector2(2f * ri * (((float)x) + (z % 2 == 0?0.0f:0.5f)), 1.5f * ro * (float)z);

        instance.localPosition = new Vector3(pos.x, 0f, pos.y);
        validPositions.Add(pos);
        places.Add(x, z, instance.Find("Mesh").gameObject.GetComponent <PlaceView>());
        return(instance);
    }
Пример #23
0
        Grid Flip(Grid tile)
        {
            Grid output = new Grid();

            foreach (var row in tile)
            {
                var copy = row.ConvertAll(x => x);
                copy.Reverse();
                output.Add(copy);
            }
            return(output);
        }
Пример #24
0
        public void AddTest()
        {
            var position = GetRandomVector3();
            var entity   = new Interaction(1, 1, position, 0, 1);

            grid.Add(entity);
            using (var enumerator = grid.Find(position, 0).GetEnumerator())
            {
                Assert.True(enumerator.MoveNext());
                Assert.AreEqual(entity, enumerator.Current);
            }
        }
Пример #25
0
        private void CreateResetStatisticButton()
        {
            var resetButton = new Button()
            {
                Text = "Reset statistic"
            };

            resetButton.Click += (sender, args) =>
            {
                var service = WaveServices.GetService <StatisticsService>();
                service.ResetStatistic();
                WaveServices.Platform.ShowMessageBox("Statistic reset", "Your statistics have been resetted");
            };

            resetButton.SetGridProperties(6, 0);
            resetButton.SetValue(GridControl.ColumnSpanProperty, 2);
            _grid.Add(resetButton);
        }
Пример #26
0
        public ISmartMenu CreateMenu()
        {
            _nextMenu = this;
            GUI.skin.button.fontSize    = 10;
            GUI.skin.label.fontSize     = 10;
            GUI.skin.textArea.fontSize  = 11;
            GUI.skin.textField.fontSize = 11;

            if (_grid == null)
            {
                _grid = new Grid(5, 5, 135, 140);
                _grid.Add(new[]
                {
                    new GridColumn(new List <IGridRenderable>
                    {
                        new GridButton("Start New Run...", () => _nextMenu = new NewRunMenu()),
                        new GridButton("Configuration...", () => _nextMenu = new ConfigurationMenu()),
                        new GridButton("Replay...", () => _nextMenu        = new ReplayMenu()),
                        new GridButton("Exit", Application.Quit),
                    }, new Padding(5, 5)),
                });
            }
            _grid.Render();
            //GUI.BeginGroup(new Rect(5, 5, 135, 140));

            //GUI.Box(new Rect(0, 0, 110, 125), "");

            //GUI.skin.button.fontSize = 10;
            //GUI.skin.label.fontSize = 10;
            //GUI.skin.textArea.fontSize = 11;
            //GUI.skin.textField.fontSize = 11;
            //if (GUI.Button(new Rect(5, 5, 100, 25), "Start New Run..."))
            //{
            //    return new NewRunMenu();
            //}
            //if (GUI.Button(new Rect(5, 35, 100, 25), "Configuration..."))
            //{
            //    return new ConfigurationMenu();
            //}
            //if (GUI.Button(new Rect(5, 65, 100, 25), "Replay..."))
            //{
            //    return new ReplayMenu();
            //}
            //if (GUI.Button(new Rect(5, 95, 100, 25), "Exit"))
            //{
            //    Application.Quit();
            //}

            //GUI.EndGroup();

            return(_nextMenu);
        }
Пример #27
0
        public void Neighbors_SingleTile_Empty()
        {
            //Arrange
            var sut      = new Grid();
            var testTile = new Tile();

            //Act
            sut.Add(testTile);
            var result = sut.Neighbors(testTile);

            //Assert
            Assert.Empty(result);
        }
Пример #28
0
 public void CreateBoard()
 {
     for (uint x = 0; x < Settings.Rows; x++)
     {
         List <ITile> row = new List <ITile>();
         for (uint y = 0; y < Settings.Cols; y++)
         {
             Floor floor = new Floor(x, y, Settings.FloorSprite);
             row.Add(floor);
         }
         Grid.Add(row);
     }
 }
Пример #29
0
        private void DrawSquareInclusion(Grid grid, int x, int y, int size)
        {
            x = x - size;
            y = y - size;

            for (int i = 0; i < size * 2; i++)
            {
                for (int j = 0; j < size * 2; j++)
                {
                    var cell = new Cell(x + i, y + j, 1).ReworkeCell(grid);
                    grid.Add(cell);
                }
            }
        }
Пример #30
0
 /// <summary>
 /// Generates the grid data structure.
 /// Iterates through the two dimensional
 /// list and creates each cell and initializes
 /// its position. Then generate that cell's
 /// neighboring cell positions.
 /// </summary>
 private void GenerateGrid()
 {
     for (var i = 0; i < GridSize; i++)
     {
         Grid.Add(new List <Cell>());
         for (var j = 0; j < GridSize; j++)
         {
             var c = new Cell();
             c.Construct(GridSize, i, j);
             c.GenerateNeighbors();
             Grid[i].Add(c);
         }
     }
 }
Пример #31
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            Grid grid = ElementFactory.CreateGrid(i => i
                                                  .Target(new DotNetConsole())
                                                  .Size(2, 2)
                                                  );

            grid.Add(0, 0, new Button("0, 0"));
            grid.Add(1, 0, new Button("1, 0"));
            grid.Add(0, 1, ElementFactory.CreateButton(i => i
                                                       .Text("<-span->")
                                                       .ColumnSpan(2)
                                                       ));

            while (true)
            {
                grid.Render();
                grid.HandleInput();
            }
        }
Пример #32
0
        public void TestAdd()
        {
            var zone = new Grid <int>(5, 10, 15);

            zone.Add(new Vector2(2, 7), 1);
            zone.Add(new Vector2(-2, 7), 2);
            zone.Add(new Vector2(2, -7), 3);
            zone.Add(new Vector2(-2, -7), 4);

            {
                var coord = zone.GetCellCoord(new Vector2(2, 7));
                var cell  = zone.GetCell(coord);
                Assert.Equal(1, cell.Count);
                Assert.Equal(1, cell.ToArray()[0]);
            }

            {
                var coord = zone.GetCellCoord(new Vector2(-2, 7));
                var cell  = zone.GetCell(coord);
                Assert.Equal(1, cell.Count);
                Assert.Equal(2, cell.ToArray()[0]);
            }

            {
                var coord = zone.GetCellCoord(new Vector2(2, -7));
                var cell  = zone.GetCell(coord);
                Assert.Equal(1, cell.Count);
                Assert.Equal(3, cell.ToArray()[0]);
            }

            {
                var coord = zone.GetCellCoord(new Vector2(-2, -7));
                var cell  = zone.GetCell(coord);
                Assert.Equal(1, cell.Count);
                Assert.Equal(4, cell.ToArray()[0]);
            }
        }
Пример #33
0
 public void CreateBlocks(List <BlockModel> blocks, bool init = false)
 {
     foreach (BlockModel block in blocks)
     {
         transforms.Add(block.x, block.z, CreateBlock(block));
     }
     if (init)
     {
         board.Add(blocks);
     }
     else
     {
         board.Push(blocks);
     }
 }
Пример #34
0
 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);
                     i = parts.Length;
                     break;
                 case 10: // RobotSpawner
                     grid.Add(ParseRobotSpawner(x, y, CopyRange(parts, i, 15)), x, y);
                     i += 15;
                     break;
                 case 11:
                     ParseLight(x, y, CopyRange(parts, i, 5));
                     i += 5;
                     break;
                 case 12:
                     textfile = ParseText(parts, i);
                     i = parts.Length;
                     break;
             }
         }
     }
     if(audiofile.Length <= 0)
         audiofile = "GetBetterJohn";
     if(textfile.Length <= 0)
         textfile = "";
     Debug.Log("Audio file: "+ audiofile + ". ");
     reader.Close();
     return grid;
 }
Пример #35
0
        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();
        }