public void UseMove(int i) { string _moveName = moves[i]; MoveFactory _factory = new MoveFactory(); this.selectedMove = _factory.GetMove(this, enemy, _moveName); this.state = CharacterState.Attacking; }
public GameResult Run() { GameResult gameResult = new GameResult(Moves.Count); MoveFactory factory = new MoveFactory(); int counter = 0; foreach (var moveRow in Moves) { gameResult.ResultList.Add(Status.StillInDanger); foreach (MoveType moveType in moveRow) { IMove move = factory.GetMove(moveType); IPosition tempPosition = move.Move(Turtle.CurrentPosition); gameResult.VisitedPositions.Add(new List <IPosition>(moveRow.Count)); if (Board.IsInBoard(tempPosition.Coordinate)) // target position must be in board { gameResult.VisitedPositions[counter].Add(tempPosition); Turtle.CurrentPosition = tempPosition; if (CheckMine(Turtle.CurrentPosition.Coordinate)) { gameResult.ResultList[counter] = Status.MineHit; break; } if (CheckExit(Turtle.CurrentPosition.Coordinate)) { gameResult.ResultList[counter] = Status.Success; break; } } else { gameResult.ResultList[counter] = Status.OutOfBoard; gameResult.VisitedPositions[counter].Add(tempPosition); break; } } counter++; Turtle.CurrentPosition = StartPosition; } return(gameResult); }