Example #1
0
    private void MoveUnit()
    {
        if (unit == null)
        {
            return;
        }

        if (pathList.Count == 0)
        {
            MoveEnded();
            return;
        }

        Vector3 endPos         = pathList[currHex].position;
        Vector2 destinationPos = (endPos - unit.position).normalized * movingSpeed;

        unit.Translate(destinationPos);
        arenaPath.HighlightHex();

        if ((unit.position - endPos).sqrMagnitude <= sqrPositionLimit)
        {
            currHex++;
            unitScript.GetAction(moveCost);
            if (currHex == pathList.Count)
            {
                MoveEnded();
            }
        }
    }