public void Transform(GridRect targetRect, float duration = 0) { // moves and resizes square var origin = rect; //Debug.Log($"GraphicEntity1: Transform {origin} -> {targetRect}"); var target = board.GridRectToRectParams(targetRect); // if target _LockProperty(GraphicEntityMutexFlag.Translation); board.LockTiles(targetRect, this); // if (duration.IsZero()) { // animatable.position = targetPosition; //} else { _RunAnimation(AnimationKeyPath.RelPosX, 0, animatable.position.x, duration, target.x); _RunAnimation(AnimationKeyPath.RelPosY, 0, animatable.position.y, duration, target.y); _RunAnimation(AnimationKeyPath.RelScaleX, 0, animatable.localScale.x, duration, target.width); _RunAnimation(AnimationKeyPath.RelScaleY, 0, animatable.localScale.y, duration, target.height); //} _UnlockProperty(GraphicEntityMutexFlag.Translation); board.UnlockTiles(origin); // relock in case we have overlap board.LockTiles(targetRect, this); rect = targetRect; }
public void Initialize(GridRect rect, Board1 board) { //Debug.Log($"Creating GraphicEntity: {rect}"); this.board = board; this.rect = rect; board.LockTiles(rect, this); var rectParams = board.GridRectToRectParams(rect); animatable = NoteFactory.CreateRect(rectParams); }