예제 #1
0
    /**
     * Only returns a value when a path is set. The NavMesh mask is a bitset representing the current area
     * 8 = Stairs / 16 = Elevator
     */
    private void ProcessCurrentArea()
    {
        NavMeshHit navMeshHit;
        int        currentMask = -1;

        if (_PoseEstimation.GetCurrentFloor() == destinationFloor)
        {
            return;
        }
        // Check if the navmesh agent is on the mesh
        if (!_NavMeshAgent.SamplePathPosition(NavMesh.AllAreas, 0f, out navMeshHit))
        {
            currentMask = navMeshHit.mask;
        }
        // Check if the user is on stairs
        if (currentMask == stairsMask)
        {
            PauseNavigation();
            var currentFloor = _PoseEstimation.GetCurrentFloor();
            _NavigationPresenter.SendObstacleMessage(currentFloor, destinationFloor, PoseEstimation.NewPosReason.EnteredStairs);
            _PoseEstimation.RequestNewPosition(PoseEstimation.NewPosReason.EnteredStairs);
        }
        // Check if the user is on the elevator
        else if (currentMask == elevatorMask)
        {
            PauseNavigation();
            var currentFloor = _PoseEstimation.GetCurrentFloor();
            _NavigationPresenter.SendObstacleMessage(currentFloor, destinationFloor, PoseEstimation.NewPosReason.EnteredElevator);
            _PoseEstimation.RequestNewPosition(PoseEstimation.NewPosReason.EnteredElevator);
        }
    }
예제 #2
0
    /**
     * Only returns a value when a path is set. The NavMesh mask is a bitset representing the current area
     * 8 = Stairs / 16 = Elevator
     */
    private void ProcessCurrentArea()
    {
        NavMeshHit navMeshHit;
        int        currentMask  = -1;
        var        currentFloor = _PoseEstimation.GetCurrentFloor();

        // Hide the map above the users floor so that its not in the way
        //Debug.Log("Current Floor: " + currentFloor);
        _ModelDatabase.HideFloorsUntil(currentFloor);

        if (_PoseEstimation.GetCurrentFloor() == destinationFloor)
        {
            return;
        }
        // Check if the navmesh agent is on the mesh
        if (!_NavMeshAgent.SamplePathPosition(NavMesh.AllAreas, 0f, out navMeshHit))
        {
            currentMask = navMeshHit.mask;
        }
        // Check if the user is on stairs
        if (currentMask == stairsMask)
        {
            PauseNavigation();

            _NavigationPresenter.SendObstacleMessage(currentFloor, destinationFloor, PoseEstimation.NewPosReason.EnteredStairs);
            _PoseEstimation.RequestNewPosition(PoseEstimation.NewPosReason.EnteredStairs);
        }
        // Check if the user is on the elevator
        else if (currentMask == elevatorMask)
        {
            PauseNavigation();
            _NavigationPresenter.SendObstacleMessage(currentFloor, destinationFloor, PoseEstimation.NewPosReason.EnteredElevator);
            _PoseEstimation.RequestNewPosition(PoseEstimation.NewPosReason.EnteredElevator);
        }
    }