public void UpdateValidPositionCriteriaList(GameObject objectClone, int playerSide) { float highestDistance = AiUtils.GetHighestDistanceBetweenPieces(playerSide, objectClone); PositionCriteria criteria = new PositionCriteria(objectClone.transform.position, objectClone.transform.rotation, highestDistance); ValidPositionCriteriaList.Add(criteria); }
public override Transform SimulateMovement(Vector3 direction, GameObject objectClone, int playerSide) { Transform pieceCloneTransform = null; bool isCurrentSimulationInProgress = true; while (isCurrentSimulationInProgress) { bool possible = false; Quaternion startRotation = objectClone.transform.rotation; do { possible = AiUtils.IsLineGapPossible(objectClone, AiUtils.GetBottomPiecePositions(playerSide, objectClone), playerSide); if (possible) { if (MovementUtils.IsRotationPossible(objectClone)) { MovementGeneratorUtils.SimulateNextRotation(objectClone, true); } else { break; } } else { break; } }while (objectClone.transform.rotation.eulerAngles.y != startRotation.eulerAngles.y); if (possible) { bool isMovePossible = MovementUtils.IsMovementPossible(direction, objectClone); if (isMovePossible) { MovementGeneratorUtils.SimulateNextTranslation(objectClone, direction); } else { return(null); } } else { return(objectClone.transform); } } return(pieceCloneTransform); }
public override Transform SimulateMovement(Vector3 direction, GameObject objectClone, int playerSide) { Transform pieceCloneTransform = null; Quaternion startRotation = objectClone.transform.rotation; Vector3 startPosition = objectClone.transform.position; do { while (true) { bool isGapPossible = AiUtils.IsLineGapPossible(objectClone, AiUtils.GetBottomPiecePositions(playerSide, objectClone), playerSide); if (!isGapPossible) { this.UpdateValidPositionCriteriaList(objectClone, playerSide); } if (!MovementUtils.IsMovementPossible(direction, objectClone)) { break; } else { MovementGeneratorUtils.SimulateNextTranslation(objectClone, direction); } } objectClone.transform.SetPositionAndRotation(startPosition, objectClone.transform.rotation); if (MovementUtils.IsRotationPossible(objectClone)) { MovementGeneratorUtils.SimulateNextRotation(objectClone, true); startPosition = objectClone.transform.position; } else { break; } }while (objectClone.transform.rotation.eulerAngles.y != startRotation.eulerAngles.y); return(pieceCloneTransform); }