示例#1
0
 public void TestSetWall()
 {
     Hero player = new Hero(2, 0, 10);
     Hero enemy = new Hero(2, 4, 10);
     Field field1 = new Field(5) { Hero1 = player, Hero2 = enemy };
     Wall wall1 = new Wall(0, 0, Logic.WallStyle.Vertical);
     Assert.AreEqual(true, field1.AddWallTest(0, 0, WallStyle.Vertical));
     Assert.AreEqual(true, field1.AddWallTest(1, 2, WallStyle.Horizontal));
     Assert.AreEqual(false, field1.AddWallTest(1, 1, WallStyle.Horizontal));
     Assert.AreEqual(true, field1.MoveHeroTest(player, 0, 1));
     Assert.AreEqual(false, field1.MoveHeroTest(player, 0, 1));
     Assert.AreEqual(true, field1.AddWallTest(0, 1, WallStyle.Vertical));
     Assert.AreEqual(false, field1.AddWallTest(0, 3, WallStyle.Vertical));
     field1.RemoveWall(0, 1, WallStyle.Vertical);
     Assert.AreEqual(true, field1.AddWallTest(0, 3, WallStyle.Vertical));
     field1.RemoveWall(0, 3, WallStyle.Vertical);
     Assert.AreEqual(true, field1.MoveHeroTest(player, -1, 0));
     Assert.AreEqual(true, field1.MoveHeroTest(player, 0, 1));
     Assert.AreEqual(true, field1.MoveHeroTest(player, 0, 1));
     Assert.AreEqual(true, field1.AddWallTest(1, 0, WallStyle.Horizontal));
     Assert.AreEqual(true, field1.AddWallTest(2, 3, WallStyle.Horizontal));
     Assert.AreEqual(false, field1.AddWallTest(2, 2, WallStyle.Vertical));
 }
示例#2
0
文件: Field.cs 项目: Nublo/Quoridor
        /// <summary>
        /// Ставит стену.
        /// Не осуществляет проверок. 
        /// </summary>
        /// <param name="i">Строка</param>
        /// <param name="j">Столбец</param>
        /// <param name="style">Направление</param>
        public void AddWall(int i, int j, WallStyle style)
        {
            Wall wall = new Wall(i, j, style);
            walls[i, j] = wall;

            if (style == WallStyle.Horizontal)
            {
                matrix.RemoveEdge(VertexNumber(i, j), VertexNumber(i + 1, j));
                matrix.RemoveEdge(VertexNumber(i, j + 1), VertexNumber(i + 1, j + 1));
            }
            else
            {
                matrix.RemoveEdge(VertexNumber(i, j), VertexNumber(i, j + 1));
                matrix.RemoveEdge(VertexNumber(i + 1, j), VertexNumber(i + 1, j + 1));
            }
        }