void MoveToPositionJunction() //if player is currently not moving, moves him current direction to next junction { try { movePosition = MapUtility.GetJunctionPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), currentDirection); } catch (Exception e) { e.GetType(); movePosition = MapUtility.GetDeadEndPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), transform.gameObject, currentDirection); } Destroy(currentTarget); currentTarget = Instantiate(targetPrefab) as GameObject; currentTarget.transform.parent = GameFunctions.GetAxisOrigin().transform; if (!GameFunctions.IsDebbuging()) { currentTarget.SetActive(false); } currentTarget.transform.localPosition = movePosition; iTween.MoveTo(transform.gameObject, iTween.Hash("position", movePosition, "speed", speed, "islocal", true, "easetype", "linear", "oncomplete", "StopMovingJunction", "name", id)); }
void MoveToPositionDeadend() //if player is currently not moving, moves him current direction to next junction { Vector3 movePosition = MapUtility.GetDeadEndPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), transform.gameObject, currentDirection); targetCoordinates = MapUtility.TranslateWorldToMapCoordinates(movePosition); iTween.MoveTo(transform.gameObject, iTween.Hash("position", movePosition, "speed", speed, "islocal", true, "easetype", iTween.EaseType.linear, "oncomplete", "StopMovingDeadend", "name", id)); }
List <int> GetDistances(List <Directions> availableDirs, GameObject target) { List <int> rList = new List <int>(); int len = availableDirs.Count; int[] targetPosition; PlayerMotion targetMotion = target.GetComponent <PlayerMotion>(); if (type == EnemyType.Aggressive || targetMotion.GetMoveDirection() == Directions.None) { targetPosition = MapUtility.TranslateWorldToMapCoordinates(target); } else { targetPosition = MapUtility.FindNextJunction(targetMotion.GetPosition(), targetMotion.GetCurrentDirection()); } int[] currentPosition = MapUtility.TranslateWorldToMapCoordinates(transform.gameObject); int[] junction = new int[2]; Vector3 junction1 = new Vector3(); for (int i = 0; i < len; i++) { try { junction = MapUtility.FindNextJunction(currentPosition, availableDirs[i]); } catch (Exception e) { e.GetType(); junction1 = MapUtility.GetDeadEndPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), transform.gameObject, availableDirs[i]); junction = MapUtility.TranslateWorldToMapCoordinates(junction1); } rList.Add(MapUtility.GetDistance(targetPosition, junction)); } return(rList); }