private void pushNextIfNotThis(Floor floor, MoveType moveType, Vector2Int truePos, Vector2Int displacement) { Vector2Int targetPos = truePos + displacement; ForegroundObject foregroundObj = floor.getForegroundObj(targetPos); if (foregroundObj != null && foregroundObj != this) { foregroundObj.OnInteraction(moveType, displacement); } }
// Moves the player using the given moveType, with the given displacement to the target position public void move(MoveType moveType, Vector2Int displacement, Vector2Int targetPosition) { StartSuccessfulStep.Invoke(); Tile prevTile = LevelManager.getTile(truePos); prevTile.OnLeave(); Tile nextTile = LevelManager.getTile(targetPosition); nextTile.OnStep(); ForegroundObject foregroundObject = LevelManager.getForegroundObject(targetPosition); if (foregroundObject != null) { foregroundObject.OnInteraction(moveType, displacement); } switch (moveType) { case (MoveType.normal): if (foregroundObject is Pushable) { playerMoveAnim("Pushing", displacement); } else { playerMoveAnim("Walking", displacement); } placeByDisplacement(displacement); MusicManager.play_by_name("footstep"); break; case (MoveType.jumpTwoTiles): playerMoveAnim("Jumping", displacement); MusicManager.play_by_name("coffee_jump"); placeByDisplacement(displacement); break; } CompleteSuccessfulStep.Invoke(); }