private function rotationControlBlocks(rotationKind:String, rotationPress:Boolean, lrMoveKind:String):Boolean
{
if (rotationKind != lastRotationKind)
{
rotationNonFirstTime = false;
lastRotationKind = rotationKind;
}
if (rotationPress == true)
{
rotationNonFirstTime = false;
}
if (rotationNonFirstTime == true)
{
return false;
}
rotationNonFirstTime = true;
if (rotationKind == rotEnum.nothing)
{
return false;
}
else
{
for (var x:int = 0; x < cbSize; x++)
{
for (var y:int = 0; y < cbSize; y++)
{
if (rotationKind == rotEnum.right)
{
aftercb[-y + cbSize - 1][x] = controlBlocks[x][y];
}
else if (rotationKind == rotEnum.left)
{
aftercb[y][-x + cbSize - 1] = controlBlocks[x][y];
}
else if (rotationKind == rotEnum.half)
{
aftercb[-x + cbSize - 1][-y + cbSize - 1] = controlBlocks[x][y];
}
else { throw Error("assert"); }
}
}
}
var bottom:int = 0;
var rightend:int = 0;
var leftend:int = cbxMax - 1;
var afbottom:int = 0;
var afrightend:int = 0;
var afleftend:int = cbxMax - 1;
for (x = 0; x < cbxMax; x++)
{
for (y = 0; y < cbyMax; y++)
{
if (controlBlocks[x][y] != null)
{
if (bottom < y) { bottom = y; }
if (rightend < x) { rightend = x; }
if (leftend > x) { leftend = x; }
}
if (aftercb[x][y] != null)
{
if (afbottom < y) { afbottom = y; }
if (afrightend < x) { afrightend = x; }
if (afleftend > x) { afleftend = x; }
}
}
}
var center:int;
var afcenter:int;
var afcbx:Number = cbx + center - afcenter;
var afcby:Number = cby + bottom - afbottom;
var afcbxt:Number;
var afcbyt:Number;
var a:int;
for (var i:int = 0; i < cbxMax; i++)
{
for (var j:int = 0; j < 8; j++)
{
afcbxt = afcbx;
afcbyt = afcby;
if (lrMoveKind == lrMovEnum.right)
{
a = i;
}
else if (lrMoveKind == lrMovEnum.left)
{
a = i * -1;
}
else
{
if (rotationKind == rotEnum.right)
{
a = i;
}
else if (rotationKind == rotEnum.left)
{
a = i * -1;
}
else if (rotationKind == rotEnum.half)
{
a = i;
}
else
{
throw Error("assert");
}
}
switch(j)
{
case 0:
afcbxt += a;
break;
case 1:
afcbxt -= a;
break;
case 2:
afcbyt -= i;
break;
case 3:
afcbxt += a;
afcbyt -= i;
break;
case 4:
afcbxt -= a;
afcbyt -= i;
break;
case 5:
afcbyt += i;
break;
case 6:
afcbxt += a;
afcbyt += i;
break;
case 7:
afcbxt -= a;
afcbyt += i;
break;
default:
throw Error("assert");
}
if (blocksHitJudge(aftercb, afcbxt, afcbyt, cbxMax, cbyMax, controlBlocks, cbx, cby, cbxMax, cbyMax, false) > 0)
{
if (blocksHitJudge(aftercb, afcbxt, afcbyt, cbxMax, cbyMax, blockMap, 0, 0, bmxMax, bmyMax, true) <= 0)
{
for (x = 0; x < cbxMax; x++)
{
for (y = 0; y < cbyMax; y++)
{
controlBlocks[x][y] = aftercb[x][y];
}
}
cbx = afcbxt;
cby = afcbyt;
dispatchEvent(new controlBlockEvent(controlBlockEvent.rotationOK, gameTime, 0, rotationKind, 0, cbx, cby));
return true;
}
}
}
}
dispatchEvent(new controlBlockEvent(controlBlockEvent.rotationNG, gameTime, 0, rotationKind, 0, cbx, cby));
return false;
}