protected override bool Perform(GameCore <Player> game, out Point newPosition) { if (CurrentGame.Player.Statuses.Contains(ParalyzedObjectStatus.StatusType)) { newPosition = CurrentGame.PlayerPosition; game.Journal.Write(new ParalyzedMessage()); return(true); } if (CurrentGame.Player.Statuses.Contains(OverweightObjectStatus.StatusType)) { newPosition = game.PlayerPosition; game.Journal.Write(new OverweightBlocksMovementMessage()); return(true); } if (CurrentGame.Player.Direction != direction) { game.Player.Direction = direction; newPosition = game.PlayerPosition; return(false); } var moveResult = MovementHelper.MoveCreature(game.Player, game.PlayerPosition, direction, true, true, false); newPosition = moveResult.NewPosition; return(moveResult.Success); }
public bool Update(INonPlayableCreatureObject creature, Point position) { var direction = RandomHelper.GetRandomElement(Enum.GetValues(typeof(Direction)).Cast <Direction>().ToArray()); var targetPosition = Point.GetPointInDirection(position, direction); MovementHelper.MoveCreature(creature, position, targetPosition, true, true, true); return(true); }
public bool TryMove(ICreatureObject creature, Point position, Point targetPosition) { var possibleMoves = GetPossibleMoves(position, targetPosition); foreach (var possibleMove in possibleMoves) { var movementResult = MovementHelper.MoveCreature(creature, position, possibleMove, true, true, true); if (movementResult.Success) { return(true); } } return(false); }
public bool Update(INonPlayableCreatureObject creature, Point position) { if (!currentDirection.HasValue) { currentDirection = GenerateDirection(); } var targetPoint = Point.GetPointInDirection(position, currentDirection.Value); var movementResult = MovementHelper.MoveCreature(creature, position, targetPoint, true, true, true); if (!movementResult.Success) { currentDirection = null; } return(true); }