/// <summary> /// Move left /// </summary> private void MoveLeft(Actor actor) { int sokoPosX = actor.PosX; int sokoPosY = actor.PosY; if (levelMap[sokoPosX - 1, sokoPosY] == ItemType.Floor || IsThereTarget(sokoPosX - 1, sokoPosY)) { if (IsThereTarget(sokoPosX - 1, sokoPosY)) { item2 = new Item(ItemType.SokobanOnGoal, sokoPosX - 1, sokoPosY); } else if (levelMap[sokoPosX - 1, sokoPosY] == ItemType.Floor) { item2 = new Item(ItemType.Sokoban, sokoPosX - 1, sokoPosY); } UpdateCurrentSokobanPosition(sokoPosX, sokoPosY); UpdateCurrentPackagePosition(sokoPosX - 2, sokoPosY, Actor.MoveDirection.Left); actor.Move(Actor.MoveDirection.Left); } }
/// <summary> /// Move up /// </summary> private void MoveUp(Actor actor) { int sokoPosX = actor.PosX; int sokoPosY = actor.PosY; // If soko can move to the next position if (levelMap[sokoPosX, sokoPosY - 1] == ItemType.Floor || IsThereTarget(sokoPosX, sokoPosY - 1)) { if (IsThereTarget(sokoPosX, sokoPosY - 1)) { item2 = new Item(ItemType.SokobanOnGoal, sokoPosX, sokoPosY - 1); } else if (levelMap[sokoPosX, sokoPosY - 1] == ItemType.Floor) { item2 = new Item(ItemType.Sokoban, sokoPosX, sokoPosY - 1); } UpdateCurrentSokobanPosition(sokoPosX, sokoPosY); UpdateCurrentPackagePosition(sokoPosX, sokoPosY - 2, Actor.MoveDirection.Up); actor.Move(Actor.MoveDirection.Up); } }
/// <summary> /// Move up /// </summary> private void MoveUp(Actor actor) { int sokoPosX = actor.PosX; int sokoPosY = actor.PosY; // If soko can move to the next position if (levelMap[sokoPosX, sokoPosY - 1] == ItemType.Floor || IsThereTarget(sokoPosX, sokoPosY - 1)) { if (IsThereTarget(sokoPosX, sokoPosY - 1)) { item2 = new Item(ItemType.SokobanOnGoal, sokoPosX, sokoPosY - 1); } else if (levelMap[sokoPosX, sokoPosY - 1] == ItemType.Floor) { item2 = new Item(ItemType.Sokoban, sokoPosX, sokoPosY - 1); } UpdateCurrentSokobanPosition(sokoPosX, sokoPosY); UpdateCurrentPackagePosition(sokoPosX, sokoPosY - 2, Actor.MoveDirection.Up); actor.Move(Actor.MoveDirection.Up); } }
/// <summary> /// Move right /// </summary> private void MoveRight(Actor actor) { int sokoPosX = actor.PosX; int sokoPosY = actor.PosY; if (levelMap[sokoPosX + 1, sokoPosY] == ItemType.Floor || IsThereTarget(sokoPosX + 1, sokoPosY)) { if (IsThereTarget(sokoPosX + 1, sokoPosY)) { item2 = new Item(ItemType.SokobanOnGoal, sokoPosX + 1, sokoPosY); } else if (levelMap[sokoPosX + 1, sokoPosY] == ItemType.Floor) { item2 = new Item(ItemType.Sokoban, sokoPosX + 1, sokoPosY); } UpdateCurrentSokobanPosition(sokoPosX, sokoPosY); UpdateCurrentPackagePosition(sokoPosX + 2, sokoPosY, Actor.MoveDirection.Right); actor.Move(Actor.MoveDirection.Right); } }