|
|
@@ -123,42 +123,4 @@ public class MoveAction : IAction {
|
|
|
private void checkIfOccupoied(Vector3 movement) {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- /* public IEnumerator PerformAction() {
|
|
|
-
|
|
|
- if (startPosition == null || (targetPosition == null && targetCreature == null) || toMove == null) {
|
|
|
- Debug.Log("Move action not setup correctly, missing startPosition " + startPosition + " or target position " + targetPosition + " or gameObject " + toMove);
|
|
|
- throw new System.Exception("Failed MoveAction");
|
|
|
- }
|
|
|
-
|
|
|
- if (targetCreature != null) {
|
|
|
- targetPosition = targetCreature.CurrentPos;
|
|
|
- }
|
|
|
-
|
|
|
- if (movedSquares >= toMove.movementRate || startPosition.Equals(targetPosition)) {
|
|
|
- yield break;
|
|
|
- }
|
|
|
- UnityEngine.Tilemaps.Tilemap tileMap = GameManagerScript.GetInstance().TileMap;
|
|
|
- Vector3Int startPositionAdjusted = tileMap.WorldToCell(startPosition);
|
|
|
- Vector3Int targetPositionAdjusted = tileMap.WorldToCell(targetPosition);
|
|
|
-
|
|
|
- Vector3Int distanceToTarget = (startPositionAdjusted - targetPositionAdjusted);
|
|
|
- Vector3Int finalPos = tileMap.WorldToCell(startPositionAdjusted - distanceToTarget);
|
|
|
-
|
|
|
- Debug.Log("Start position " + startPosition + " Adjusted: " + startPositionAdjusted + " final pos " + finalPos + " distance " + (-(startPositionAdjusted - targetPositionAdjusted)));
|
|
|
-
|
|
|
- float time = 30 / 6f;
|
|
|
- float eleapsedTime = 0f;
|
|
|
- while (eleapsedTime < time) {
|
|
|
- if (targetCreature != null) {
|
|
|
- targetPosition = targetCreature.CurrentPos;
|
|
|
- targetPositionAdjusted = tileMap.WorldToCell(targetPosition);
|
|
|
- distanceToTarget = (startPositionAdjusted - targetPositionAdjusted);
|
|
|
- finalPos = tileMap.WorldToCell(startPositionAdjusted - distanceToTarget);
|
|
|
- }
|
|
|
- toMove.transform.position = Vector3.Lerp(tileMap.GetCellCenterWorld(startPositionAdjusted), tileMap.GetCellCenterWorld(finalPos), (eleapsedTime / time));
|
|
|
- eleapsedTime += Time.deltaTime;
|
|
|
- yield return null;
|
|
|
- }
|
|
|
- } */
|
|
|
}
|