public void Move(Map map, Player player) { if (HisLastStep is Money) { map.MapObject[X, Y] = new Money(); map.DrawInCoordinate(X, Y, new Money()); } else { map.MapObject[X, Y] = null; map.DrawInCoordinate(X, Y, null); } if (!(map.MapObject[X, Y - 1] is Wall) && Y - player.Y > 0) { HisLastStep = map.MapObject[X, --Y]; } else if (!(map.MapObject[X, Y + 1] is Wall) && Y - player.Y < 0) { HisLastStep = map.MapObject[X, ++Y]; } else if (!(map.MapObject[X - 1, Y] is Wall) && X - player.X > 0) { HisLastStep = map.MapObject[--X, Y]; } else if (!(map.MapObject[X + 1, Y] is Wall) && X - player.X < 0) { HisLastStep = map.MapObject[++X, Y]; } map.MapObject[X, Y] = this; map.DrawInCoordinate(X, Y, this); }
public void Move(ConsoleKeyInfo key, Map map) { if (key.Key == ConsoleKey.LeftArrow && !(map.MapObject[X - 1, Y] is Wall)) { if (map.MapObject[X - 1, Y] is Money) { Score.Account(); } map.MapObject[X, Y] = null; map.DrawInCoordinate(X, Y, null); map.MapObject[--X, Y] = this; } else if (key.Key == ConsoleKey.RightArrow && !(map.MapObject[X + 1, Y] is Wall)) { if (map.MapObject[X + 1, Y] is Money) { Score.Account(); } map.MapObject[X, Y] = null; map.DrawInCoordinate(X, Y, null); map.MapObject[++X, Y] = this; } else if (key.Key == ConsoleKey.UpArrow && !(map.MapObject[X, Y - 1] is Wall)) { if (map.MapObject[X, Y - 1] is Money) { Score.Account(); } map.MapObject[X, Y] = null; map.DrawInCoordinate(X, Y, null); map.MapObject[X, --Y] = this; } else if (key.Key == ConsoleKey.DownArrow && !(map.MapObject[X, Y + 1] is Wall)) { if (map.MapObject[X, Y + 1] is Money) { Score.Account(); } map.MapObject[X, Y] = null; map.DrawInCoordinate(X, Y, null); map.MapObject[X, ++Y] = this; } map.DrawInCoordinate(X, Y, this); }