예제 #1
0
        public void SpotMove()
        {
            var cells = new CellsField();

            cells.Fill(3, 3);
            var field = InitByConf(new [, ]
            {
                { 1, 0, 0 },
                { 1, 1, 0 },
                { 0, 0, 0 }
            }, 3, 3, cells);

            var a = field[0, 0];
            var b = field[0, 1];
            var c = field[1, 1];

            Assert.AreEqual(cells.GetCellAt(0, 0), a.GetCell());
            Assert.AreEqual(cells.GetCellAt(0, 1), b.GetCell());
            Assert.AreEqual(cells.GetCellAt(1, 1), c.GetCell());

            var move = new SpotMove(cells.GetCellAt(1, 1), cells.GetCellAt(1, 2));

            move.Step();
            move.Step();

            Assert.AreEqual(cells.GetCellAt(0, 1), a.GetCell());
            Assert.AreEqual(cells.GetCellAt(1, 1), b.GetCell());
            Assert.AreEqual(cells.GetCellAt(1, 2), c.GetCell());

            move = new SpotMove(cells.GetCellAt(1, 2), cells.GetCellAt(2, 2));
            move.Step();
            move.Step();

            Assert.AreEqual(cells.GetCellAt(1, 1), a.GetCell());
            Assert.AreEqual(cells.GetCellAt(1, 2), b.GetCell());
            Assert.AreEqual(cells.GetCellAt(2, 2), c.GetCell());
        }
예제 #2
0
        public void SpotMove2()
        {
            var cells = new CellsField();

            cells.Fill(3, 6);
            var field = InitByConf(new [, ]
            {
                { 1, 0, 0 },
                { 1, 1, 1 },
                { 1, 0, 0 },
                { 1, 0, 0 },
                { 1, 0, 0 },
                { 1, 0, 0 }
            }, 6, 3, cells);

            //a
            //b c d
            //e
            //
            //y
            //z

            var a = field[0, 0];
            var b = field[0, 1];
            var c = field[1, 1];
            var d = field[2, 1];
            var e = field[0, 2];

            var y = field[0, 4];
            var z = field[0, 5];

            Assert.IsNotNull(a.GetLinkWith(b));
            Assert.IsNotNull(b.GetLinkWith(c));
            Assert.IsNotNull(c.GetLinkWith(d));
            Assert.IsNotNull(b.GetLinkWith(e));
            Assert.IsNotNull(y.GetLinkWith(z));
            Assert.AreEqual(a, new SpotRunner(z).Last());

            foreach (var spot in new SpotRunner(z))
            {
                Debug.Log(spot.GetFullName() + " c:" + spot.Links.Count);
            }

            var move = new SpotMove(cells.GetCellAt(0, 5), cells.GetCellAt(1, 5));

            move.Step();
            move.Step();

            //
            //a c d
            //b
            //e
            //
            //y
            //z

            foreach (var spot in new SpotRunner(z))
            {
                Debug.Log(spot.GetFullName() + " c:" + spot.Links.Count);
            }

            Assert.IsNotNull(a.GetLinkWith(c));
            Assert.IsNotNull(d.GetLinkWith(c));
            Assert.IsNotNull(b.GetLinkWith(a));
            Assert.IsNotNull(b.GetLinkWith(e));
            Assert.IsNotNull(y.GetLinkWith(z));
        }