Exemple #1
0
    private bool Initialize()
    {
        if (mState != null)
        {
            mState.Exit();
        }

        mState = null;

        NavManagerProvider provider =
            (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            return(false);
        }

        NavManager manager = provider.CreateManager();

        if (manager == null)
        {
            Debug.LogError(string.Format("{0}: Could not get the navigation manager.", name));

            return(false);
        }

        mHelper = manager.NavGroup;

        return(true);
    }
Exemple #2
0
    public bool SetState(QEStateType state)
    {
        if (State == QEStateType.Inactive && !Initialize())
        {
            return(false);
        }

        if (mState != null)
        {
            mState.Exit();
        }

        mState = null;

        switch (state)
        {
        case QEStateType.GetNearestPointG:
            mState = new GetNearestPointG();
            break;

        case QEStateType.FindDistanceToWall:
            mState = new FindDistanceToWall();
            break;

        case QEStateType.FindPolysByRadius:
            mState = new FindPolysByRadius();
            break;

        case QEStateType.FindPolysByConvex:
            mState = new FindPolysByConvex();
            break;

        case QEStateType.GetPolysLocal:
            mState = new GetPolysLocal();
            break;

        case QEStateType.GetNearestPointL:
            mState = new GetNearestPointL();
            break;

        case QEStateType.GetNearestPointF:
            mState = new GetNearestPointF();
            break;

        case QEStateType.GetPolyHeight:
            mState = new GetPolyHeight();
            break;

        case QEStateType.GetPolys:
            mState = new GetPolys();
            break;

        case QEStateType.GetWallSegments:
            mState = new GetWallSegments();
            break;

        case QEStateType.GetSegments:
            mState = new GetSegments();
            break;

        case QEStateType.FindPath:
            mState = new FindPath();
            break;

        case QEStateType.StraightPath:
            mState = new StraightPath();
            break;

        case QEStateType.Raycast:
            mState = new RaycastQE();
            break;

        case QEStateType.MoveOnSurface:
            mState = new MoveAlongSurface();
            break;
        }

        mState.Enter(mHelper);

        return(true);
    }