Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum MovementDirections
- {
- Up, // (0,1)
- Down, // (0,-1)
- Left, // (-1,0)
- Right // (1,0)
- }
- public int PosX { get; set; }
- public int PosY { get; set; }
- public List<Cell> GetCellsOnPath(MovementDirections movementDirection) // The direction Vector
- {
- List<Cell> cellsOnPath = new List<Cell>();
- switch (movementDirection)
- {
- case MovementDirections.Up:
- for (int i = 0; i < mapCells.Count; i++)
- {
- Cell currentCell = mapCells[i];
- if (currentCell.PosY > playerInfo.CurrentCell.PosY)
- {
- cellsOnPath.Add(currentCell);
- }
- }
- break;
- case MovementDirections.Down:
- for (int i = 0; i < mapCells.Count; i++)
- {
- Cell currentCell = mapCells[i];
- if (currentCell.PosY < playerInfo.CurrentCell.PosY)
- {
- cellsOnPath.Add(currentCell);
- }
- }
- break;
- case MovementDirections.Left:
- for (int i = 0; i < mapCells.Count; i++)
- {
- Cell currentCell = mapCells[i];
- if (currentCell.PosX < playerInfo.CurrentCell.PosX)
- {
- cellsOnPath.Add(currentCell);
- }
- }
- break;
- case MovementDirections.Right:
- for (int i = 0; i < mapCells.Count; i++)
- {
- Cell currentCell = mapCells[i];
- if (currentCell.PosX > playerInfo.CurrentCell.PosX)
- {
- cellsOnPath.Add(currentCell);
- }
- }
- break;
- }
- return cellsOnPath;
- }
Add Comment
Please, Sign In to add comment