Esempio n. 1
0
    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);
    }