Esempio n. 1
0
 public void RotateTest()
 {
     for (var i = 0; i < TestNum; i++)
     {
         var b = _factory.GenTetris();
         b.Rotate();
         Assert.AreEqual(1, b.Direction);
         b.Rotate();
         Assert.AreEqual(2, b.Direction);
         b.Rotate();
         Assert.AreEqual(3, b.Direction);
         b.Rotate();
         Assert.AreEqual(0, b.Direction);
         b.CounterRotate();
         Assert.AreEqual(3, b.Direction);
         b.CounterRotate();
         Assert.AreEqual(2, b.Direction);
         b.CounterRotate();
         Assert.AreEqual(1, b.Direction);
         b.CounterRotate();
         Assert.AreEqual(0, b.Direction);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 生成方块
        /// </summary>
        private void GenTetris()
        {
            if (_state == 0)
            {
                return;
            }
            if (Block != null)
            {
                throw new Exception("multiple sprite generating");
            }
            var b = _factory.GenTetris();

            b.LPos = Height - 1;
            if (Try(b))
            {
                Block = b;
            }
            else
            {
                End();
            }
        }