protected bool MoveTo(int newDirection) { if (CurrentFloor == null) { return(false); } var moved = false; switch (newDirection) { case 0: if (CurrentFloor.UpDirection != null) { CurrentFloor.RemovePlayer(this); CurrentFloor = CurrentFloor.UpDirection; moved = true; } break; case 1: if (CurrentFloor.DownDirection != null) { CurrentFloor.RemovePlayer(this); CurrentFloor = CurrentFloor.DownDirection; moved = true; } break; case 2: if (CurrentFloor.LeftDirection != null) { CurrentFloor.RemovePlayer(this); CurrentFloor = CurrentFloor.LeftDirection; moved = true; } break; case 3: if (CurrentFloor.RightDirection != null) { CurrentFloor.RemovePlayer(this); CurrentFloor = CurrentFloor.RightDirection; moved = true; } break; default: break; } if (moved) { CurrentFloor.InsertPlayer(this); transform.position = CurrentFloor.transform.position; transform.parent = CurrentFloor.transform; } return(moved); }
private void ConnectIndividuals(GridPosition floorPos, DownFloor currentFloor, int direction) { if (floorPos.x >= 0 && floorPos.x < columns && floorPos.y >= 0 && floorPos.y < rows) { switch (direction) { case 0: currentFloor.UpDirection = floorGrid[floorPos.x, floorPos.y]; break; case 1: currentFloor.DownDirection = floorGrid[floorPos.x, floorPos.y]; break; case 2: currentFloor.LeftDirection = floorGrid[floorPos.x, floorPos.y]; break; case 3: currentFloor.RightDirection = floorGrid[floorPos.x, floorPos.y]; break; default: break; } } }
public override void SetCurrentFloor(DownFloor floor) { CurrentFloor = floor; }
public abstract void SetCurrentFloor(DownFloor floor);