Beispiel #1
0
    /// <summary>
    /// 가장 먼 위치를 측정해서 반환함
    /// </summary>
    private Vector3 GetFarPosition()
    {
        int positionNumber = 0;

        Vector3 firstHigh = movePositions[0].position;

        if (firstHigh.Equals(currentDestination))
        {
            firstHigh = movePositions[1].position;
        }

        float HighDistance = Lect.Distance(transform.position, firstHigh);

        for (int i = 1; i < movePositions.Length; i++)
        {
            if (movePositions[i].position.Equals(currentDestination) ||
                movePositions[i].position.Equals(previousDestination))
            {
                continue;
            }

            float currentDistance = Lect.Distance(transform.position, movePositions[i].position);
            if (HighDistance < currentDistance)
            {
                positionNumber = i;
                HighDistance   = currentDistance;
            }
        }

        currentDestination = movePositions[positionNumber].position;
        return(currentDestination);
    }
Beispiel #2
0
    /// <summary>
    /// 가장 가까운 위치를 측정해서 반환함
    /// </summary>
    private Vector3 GetClosePosition()
    {
        int positionNumber = 0;

        Vector3 firstLow = movePositions[0].position;

        if (firstLow.Equals(currentDestination))
        {
            firstLow = movePositions[1].position;
        }

        float lowDistance = Lect.Distance(transform.position, firstLow);

        for (int i = 1; i < movePositions.Length; i++)
        {
            if (movePositions[i].position.Equals(currentDestination) ||
                movePositions[i].position.Equals(previousDestination))
            {
                continue;
            }

            float currentDistance = Lect.Distance(transform.position, movePositions[i].position);
            if (lowDistance > currentDistance)
            {
                positionNumber = i;
                lowDistance    = currentDistance;
            }
        }

        previousDestination = currentDestination;
        currentDestination  = movePositions[positionNumber].position;
        return(currentDestination);
    }