public MinesValidator(Board board, StartingPosition startingPosition, ExitPosition exitPosition) { RuleFor(m => m) .NotEqual(startingPosition.Tile).WithMessage($"There is a mine on starting position.") .NotEqual(exitPosition.Tile).WithMessage($"There is a mine on exit position.") .SetValidator(m => new TileValidator($"Mines {m.GetValueOrDefault()}", board.Rows, board.Columns)).WithMessage("Some of the mines are invalid."); }
protected WaitForSeconds inputHoldWait; // The WaitForSeconds used to make the user wait before input is handled again. protected virtual void Start() { handleInput = false; // Create the wait based on the delay. inputHoldWait = new WaitForSeconds(inputHoldDelay); string startingPositionName = ""; Transform startingPosition = null; if (!playerSaveData) { Debug.LogWarning("No PlayerSaveData Asset attached to Player controller: " + name); } else { //Load the starting position from the save data and find the transform from the starting position's name. playerSaveData.Load(StartingPosition.startingPositionKey, ref startingPositionName); startingPosition = StartingPosition.FindStartingPosition(startingPositionName); } //Set the player's position based on the starting position. if (startingPosition) { transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; } else if (!startingPositionName.Equals("")) { Debug.LogWarning("No starting position found with name " + startingPositionName); } StartCoroutine(holdInput()); }
public async Task Genrate() { _startingpos = (StartingPosition)NumGen.Next(0, 5) /*StartingPosition.Center*/; LogToUiThread($"Starting position : {_startingpos}"); int roomcount = _dp.RoomNumber.Next(); LogToUiThread($"Generating {roomcount} rooms"); for (int i = 0; i < roomcount; i++) { bool isFirst = i == 0; Direction dir = Direction.North; if (isFirst) { dir = GetDirByStartupPos(); } else { dir = (Direction)NumGen.Next(0, 4); } var r = await GenerateRoom(dir, (Corridors.Count > 0)?Corridors[i - 1] : null, (isFirst)); Rooms.Add(r); //si dernière salle, pas couloir if (i < roomcount - 1) { var c = await GenerateCorridor(r); Corridors.Add(c); } } }
protected override void Write(Client psr, NWriter wtr) { wtr.Write(Time); wtr.Write(BulletId); wtr.Write(ContainerType); StartingPosition.Write(psr, wtr); wtr.Write(Angle); }
public override int GetHashCode() { int hashCode = -1795512632; hashCode = hashCode * -1521134295 + StartingPosition.GetHashCode(); hashCode = hashCode * -1521134295 + EndingPosition.GetHashCode(); return(hashCode); }
protected override void Write(DWriter wtr) { wtr.Write(Time); wtr.Write(BulletId); wtr.Write(ContainerType); StartingPosition.Write(wtr); wtr.Write(Angel); }
void Start() { string startingPositionName = ""; playerSaveData.Load(startingPositionKey, ref startingPositionName); Transform startingPosition = StartingPosition.FindStartingPosition(startingPositionName); transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> public override int GetHashCode() { unchecked { var hashCode = ProjectName != null?ProjectName.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (StartingPosition != null ? StartingPosition.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EndingPosition != null ? EndingPosition.GetHashCode() : 0); return(hashCode); } }
public void When_validating_starting_position_and_tile_and_direction_are_null_then_return_error() { var startingPosition = new StartingPosition(); var startingPositionValidator = new StartingPositionValidator(2, 2); var results = startingPositionValidator.Validate(startingPosition); results.Errors.Count.Should().Be(2); results.Errors[0].ErrorMessage.Should().Be("StartingPosition tile should not be null."); results.Errors[1].ErrorMessage.Should().Be("Direction should not be null."); }
public HashSet <IntVec3> MakeProjectileLine(Vector3 start, Vector3 end, Map map) { var resultingLine = new ShootLine(start.ToIntVec3(), end.ToIntVec3()); var points = resultingLine.Points(); HashSet <IntVec3> positions = new HashSet <IntVec3>(); var currentPos = CurPosition; currentPos.y = 0; var startingPosition = StartingPosition; startingPosition.y = 0; var destination = new Vector3(currentPos.x, currentPos.y, currentPos.z); Vector3 pos = (startingPosition + currentPos) / 2f; pos.y = 10; pos += Quaternion.Euler(0, (startingPosition - currentPos).AngleFlat(), 0) * this.def.startingPositionOffset; var distance = Vector3.Distance(startingPosition, currentPos) * this.def.totalSizeScale; var distanceToTarget = Vector3.Distance(startingPosition, currentPos); var widthFactor = distance / distanceToTarget; var width = distance * this.def.widthScaleFactor * widthFactor; var height = distance * this.def.heightScaleFactor; var centerOfLine = pos.ToIntVec3(); var startPosition = StartingPosition.ToIntVec3(); var endPosition = this.CurPosition.ToIntVec3(); if (points.Any()) { foreach (var cell in GenRadial.RadialCellsAround(start.ToIntVec3(), height, true)) { if (centerOfLine.DistanceToSquared(endPosition) >= cell.DistanceToSquared(endPosition) && startPosition.DistanceTo(cell) > def.minDistanceToAffect) { var nearestCell = points.MinBy(x => x.DistanceToSquared(cell)); if ((width / height) * 2.5f > nearestCell.DistanceToSquared(cell)) { positions.Add(cell); } } } foreach (var cell in points) { var startCellDistance = startPosition.DistanceTo(cell); if (startCellDistance > def.minDistanceToAffect && startCellDistance <= startPosition.DistanceTo(endPosition)) { positions.Add(cell); } } } return(positions); }
private void Start() { interactionHold = new WaitForSeconds(interactionDuration); controller.detectCollisions = false; string startPosName = ""; playerSaveData.Load(startingPositionKey, ref startPosName); Transform startingPosition = StartingPosition.FindStartingPosition(startPosName); transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; }
protected override void Write(Client psr, NWriter wtr) { wtr.Write(BulletId); wtr.Write(OwnerId); wtr.Write(BulletType); StartingPosition.Write(psr, wtr); wtr.Write(Angle); wtr.Write(Damage); if (NumShots == 1 || AngleInc == 0) { return; } wtr.Write(NumShots); wtr.Write(AngleInc); }
void Start() { agent.updateRotation = false; inputHoldWait = new WaitForSeconds(inputHoldDelay); string startingPositionName = ""; playerSaveData.Load(startingPositionKey, ref startingPositionName); Transform startingPosition = StartingPosition.FindStartingPosition(startingPositionName); transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; destinationPosition = transform.position; }
// This function will be called just after a scene is finished loading. // It must call saveData.Load with a ref parameter to get the data out. protected void Load() { // Load the starting position from the save data and find the transform from the starting position's name. string startingPositionName = "00StartPosition"; playerSaveData.Load(startingPositionKey, ref startingPositionName); Transform startingPosition = StartingPosition.FindStartingPosition(startingPositionName); if (startingPosition) { // Set the player's position and rotation based on the starting position. transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; Debug.Log(startingPosition.position); } }
public void StartingPositionParameters ( StartingPosition inputStartingPosition, float inputBuildingX = 0, float inputBuildingY = 0, float inputBuildingWidth = 0, float inputBuildingHeight = 0, ActionTileProperties.ActionType inputReplaceTileType = ActionTileProperties.ActionType.Movement_Valid ) { startingPosition = inputStartingPosition; buildingX = inputBuildingX; buildingY = inputBuildingY; buildingWidth = inputBuildingWidth; buildingHeight = inputBuildingHeight; replaceTileType = inputReplaceTileType; }
public override List <Tuple <int, int> > GetPossibleMoves(ChessBoard cb) { Tuple <int, int> position = Position; List <Tuple <int, int> > nonCaptureMoves = new List <Tuple <int, int> >(), captureMoves = new List <Tuple <int, int> >(), allMoves = new List <Tuple <int, int> >(); bool isPlayerBlack = (GetPlayer() == Player.Black); if (StartingPosition.Equals(position) && cb.GetPieceInPosition(new Tuple <int, int>(position.Item1 + (isPlayerBlack ? 1 : -1), position.Item2)) == null) { nonCaptureMoves.Add(new Tuple <int, int>(position.Item1 + (isPlayerBlack ? 2 : -2), position.Item2)); // moveForwardDouble } nonCaptureMoves.Add(new Tuple <int, int>(position.Item1 + (isPlayerBlack ? 1 : -1), position.Item2)); // moveForward captureMoves.Add(new Tuple <int, int>(position.Item1 + (isPlayerBlack ? 1 : -1), position.Item2 + 1)); // moveCaptureRight captureMoves.Add(new Tuple <int, int>(position.Item1 + (isPlayerBlack ? 1 : -1), position.Item2 - 1)); // moveCaptureLeft foreach (Tuple <int, int> move in nonCaptureMoves) { if (cb.GetPieceInPosition(move) == null) { allMoves.Add(move); } } foreach (Tuple <int, int> move in captureMoves) { ChessPiece capturedPiece = cb.GetPieceInPosition(move); if (capturedPiece != null && capturedPiece.GetPlayer() != GetPlayer()) { allMoves.Add(move); } } return(allMoves); }
/// <summary> /// Determines the true starting position based on a potentially incomplete starting position. /// </summary> /// <param name="position">The incomplete position to extrapolate.</param> /// <returns>The completed starting position.</returns> /// <exception cref="MalformedStartingPositionException">On invalid starting position.</exception> public static StartingPosition ExtrapolateStartingPosition(StartingPosition position) { string pgn = position.Pgn; string fen = position.Fen; if (fen != null) { return(position); } var parser = new PgnGameParser(); try { var pgnGame = parser.ParsePgn(pgn); var ply = pgnGame.FirstMove; while (ply.NextMoveInMainLine != null) { ply = ply.NextMoveInMainLine; } var board = ply.ToBoard(); fen = board.ToFen(); return(new StartingPosition() { Fen = fen, Pgn = pgn, }); } catch (Exception e) { if (e is AlienChessException || e is PgnFormatException) { throw new MalformedStartingPositionException("The provided starting position could not be parsed from the PGN format.", e); } else { throw new MalformedStartingPositionException("The provided starting position could not be parsed from the PGN format."); } } }
public void When_validating_mines_and_one_of_then_is_equal_starting_or_exit_position_then_return_error() { var board = new Board { Rows = 4, Columns = 5 }; var startingPosition = new StartingPosition { Tile = new Point(4, 2) }; var exitPosition = new ExitPosition { Tile = new Point(4, 2) }; var minesValidator = new MinesValidator(board, startingPosition, exitPosition); var mine = new Point(4, 2); var results = minesValidator.Validate(mine); results.Errors.Count.Should().Be(2); results.Errors[0].ErrorMessage.Should().Be("There is a mine on starting position."); results.Errors[1].ErrorMessage.Should().Be("There is a mine on exit position."); }
// The maximum distance from the nav mesh a click can be to be accepted. private void Start() { // The player will be rotated by this script so the nav mesh agent should not rotate it. agent.updateRotation = false; // Create the wait based on the delay. inputHoldWait = new WaitForSeconds(inputHoldDelay); // Load the starting position from the save data and find the transform from the starting position's name. string startingPositionName = ""; playerSaveData.Load(startingPositionKey, ref startingPositionName); Transform startingPosition = StartingPosition.FindStartingPosition(startingPositionName); // Set the player's position and rotation based on the starting position. transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; // Set the initial destination as the player's current position. destinationPosition = transform.position; }
private void Start() { if (UnityEngine.EventSystems.EventSystem.current == null) { Instantiate(eventSystemPrefab); } agent.updateRotation = false; inputHoldWait = new WaitForSeconds(inputHoldDelay); string startingPositionName = ""; playerSaveData.Load(startingPositionKey, ref startingPositionName); Transform startingPosition = StartingPosition.FindStartingPosition(startingPositionName); if (startingPosition) { transform.position = startingPosition.position; transform.rotation = startingPosition.rotation; } destinationPosition = transform.position; }
private void OnEnable() { targetStartingPosition = target as StartingPosition; }