private bool CanMoveLeft(BlockDataPiece piece) { if (!HasFloor(piece)) { return(false); } return(!HasWallLeft(piece)); }
public bool HasFloor(BlockDataPiece piece) { var piecePos = GetPosition(piece); foreach (var otherPiece in pieces) { var otherPos = GetPosition(otherPiece); if (Math.Abs(piecePos.x - otherPos.x) < .01f && Math.Abs(piecePos.y - (otherPos.y + 1)) < .01f) { return(false); } } return(true); }
public bool HasStairsUpLeft(BlockDataPiece piece) { if (Math.Abs(transform.eulerAngles.z) < .01f) { return(piece.stairL0); } if (Math.Abs(transform.eulerAngles.z - 90f) < .01f) { return(piece.stairL90); } if (Math.Abs(transform.eulerAngles.z - 180f) < .01f) { return(piece.stairL180); } if (Math.Abs(transform.eulerAngles.z - 270f) < .01f) { return(piece.stairL270); } return(false); }
public bool HasWallLeft(BlockDataPiece piece) { if (Math.Abs(transform.eulerAngles.z) < .01f) { return(piece.wallLeft); } if (Math.Abs(transform.eulerAngles.z - 90f) < .01f) { return(piece.wallUp); } if (Math.Abs(transform.eulerAngles.z - 180f) < .01f) { return(piece.wallRight); } if (Math.Abs(transform.eulerAngles.z - 270f) < .01f) { return(piece.wallDown); } return(false); }
public Vector3 GetPosition(BlockDataPiece piece) { var offset = new Vector3(piece.xOffset - .5f, piece.yOffset - .5f, 0); return(transform.TransformPoint(offset)); }