public override void addCb(string cmd, int lineNum) { xCount++; Direction tempDir = xDir; if (xCount == xLimit) { xCount = 0; xDir = CoorUtil.inverseDirection(xDir); zCount++; tempDir = zDir; if (zCount == zLimit) { tempDir = Direction.positiveY; zCount = 0; zDir = CoorUtil.inverseDirection(zDir); yCount++; } } if (isNewChain) { isNewChain = false; cbStack.Push(new CommandBlock(cmd, newCoor[0], newCoor[1], newCoor[2], CoorUtil.directionToCBDamage(tempDir), lineNum)); } else { int[] coor = getNextCbCoor(); cbStack.Push(new CommandBlock(cmd, coor[0], coor[1], coor[2], CoorUtil.directionToCBDamage(tempDir), lineNum)); } }
public void CBDamageToDirectionTest() { Assert.AreEqual(Direction.positiveX, CoorUtil.CBDamageToDirection(5)); Assert.AreEqual(Direction.negativeX, CoorUtil.CBDamageToDirection(4)); Assert.AreEqual(Direction.positiveZ, CoorUtil.CBDamageToDirection(3)); Assert.AreEqual(Direction.negativeZ, CoorUtil.CBDamageToDirection(2)); Assert.AreEqual(Direction.positiveY, CoorUtil.CBDamageToDirection(1)); Assert.AreEqual(Direction.negativeY, CoorUtil.CBDamageToDirection(0)); }
public override void addCb(string cmd, int lineNum) { if (cmd.Equals("changeD")) { if (dir != Direction.positiveX && dir != Direction.negativeX) { cbStack.Peek().setDirection(CoorUtil.directionToCBDamage(Direction.positiveX)); } else { cbStack.Peek().setDirection(CoorUtil.directionToCBDamage(Direction.positiveZ)); } dir = CoorUtil.inverseDirection(dir); return; } Direction tempDir = dir; if (limit != 0 && autoChangeDirection) { rowCbCount++; if (rowCbCount == limit) { if (dir != Direction.positiveX && dir != Direction.negativeX) { tempDir = Direction.positiveX; } else { tempDir = Direction.positiveZ; } rowCbCount = 0; dir = CoorUtil.inverseDirection(dir); } } int[] coor = getNextCbCoor(); if (isNewChain) { isNewChain = false; coor = newCoor; } cbStack.Push(new CommandBlock(cmd, coor[0], coor[1], coor[2], CoorUtil.directionToCBDamage(tempDir), lineNum)); }
public int[] getNextCbCoor() { int[] coor = { relativeX, relativeY, relativeZ }; return(CoorUtil.move(coor, CoorUtil.CBDamageToDirection(damage))); }