示例#1
0
 public void ChangeInteractionStateTo(InteractionState interactionState)
 {
     if (interactionState == currentInteractionState)
     {
         Debug.Log($"INFO INTERACTION STATE: State stayed the same: State {currentInteractionState.ToString("g")}. ");
         return;
     }
     ActivateCorrespondingInteractionHandler(interactionState);
     currentInteractionState = interactionState;
 }
    private void SetInteractionState(InteractionState state)
    {
        switch (state)
        {
        case InteractionState.None:
            spinMenu.Show();
            rangedInteractions.Enable();
            break;

        case InteractionState.Grabbing:
            //closeInteractionsScript.DisableAndInterrupt();
            spinMenu.Disable();
            rangedInteractions.Disable();
            break;

        case InteractionState.CloseInteracting:
            spinMenu.Disable();
            rangedInteractions.Disable();
            break;

        case InteractionState.RangedInteracting:
            spinMenu.Hide();
            break;

        case InteractionState.RangedMenuOpen:
            break;
        }

        activeState = state;
        Debug.Log("Controller interaction changed to " + state.ToString());
    }
示例#3
0
    private void ActivateCorrespondingInteractionHandler(InteractionState interactionState)
    {
        // Check how many interaction handlers are active
        int numberOfActiveInteractionHandlers = interactionHandlers.Count(handler => handler.IsActive);

        if (numberOfActiveInteractionHandlers != 1)
        {
            Debug.LogError($"ERROR INTERACTION STATE: When trying to change the current interaction state " +
                           $"\"{currentInteractionState.ToString("g")}\" to the new state \"{interactionState.ToString("g")}\", a total of " +
                           $"{numberOfActiveInteractionHandlers} Interaction Handlers were active, but this number should be 1. ");
        }

        // Deactivate currently active interaction Handler
        foreach (IInteractionStateHandleable interactionHandler in interactionHandlers)
        {
            if (!interactionHandler.IsActive)
            {
                continue;
            }

            interactionHandler.Exit();
            interactionHandler.IsActive = false;
        }

        // Activate corresponding interaction handler
        switch (interactionState)
        {
        case InteractionState.LookingAround:
            lookingAroundHandler.Enter();
            lookingAroundHandler.IsActive = true;
            break;

        case InteractionState.Placing:
            placingHandler.Enter();
            placingHandler.IsActive = true;
            break;

        case InteractionState.Demolishing:
            demolishingHandler.Enter();
            demolishingHandler.IsActive = true;
            break;

        case InteractionState.InMenu:
            inMenuHandler.Enter();
            inMenuHandler.IsActive = true;
            break;

        default:
            Debug.LogError($"ERROR INTERACTION STATE: Unsupported state \"{interactionState.ToString("g")}\". ");
            break;
        }
    }
示例#4
0
 /// <summary>
 /// Checks to see if there is an ongoing interaction. Note that this is specifically for when the user is performing an interaction, not when they only have it selected.
 /// </summary>
 /// <returns>True if the user is currently performing an interaction, otherwise returns false</returns>
 private bool IsInteracting()
 {
     return(new string[] { "rangedbrushing", "rangedinteracting", "rangedpulling", "detailsondemand" }.Contains(activeState.ToString().ToLower()));
 }
示例#5
0
    /// <summary>
    /// This method changes the InteractionState to the one specified. Note that this does not check for any pre-conditions before switching the state
    /// and should only be called where allowed.
    /// </summary>
    /// <param name="state">The InteractionState to change to</param>
    private void SetInteractionState(InteractionState state)
    {
        // If ranged interactions are disabled, don't allow any interaction changes (mainly when finishing an existing interaction)
        if (!isEnabled)
        {
            state = InteractionState.None;
        }

        if (activeState == state)
        {
            return;
        }

        if (hiddenState == InteractionState.None)
        {
            // If tool is being enabled
            if (activeState == InteractionState.None && IsInteractionTool(state))
            {
                DataLogger.Instance.LogActionData(this, PhotonNetwork.LocalPlayer, PhotonNetwork.LocalPlayer, state + " start");
            }

            // If tool is being swapped
            if (IsInteractionTool(activeState) && IsInteractionTool(state))
            {
                DataLogger.Instance.LogActionData(this, PhotonNetwork.LocalPlayer, PhotonNetwork.LocalPlayer, activeState + " end");
                DataLogger.Instance.LogActionData(this, PhotonNetwork.LocalPlayer, PhotonNetwork.LocalPlayer, state + " start");
            }

            // If tool is being removed
            else if (IsInteractionTool(activeState) && state == InteractionState.None)
            {
                DataLogger.Instance.LogActionData(this, PhotonNetwork.LocalPlayer, PhotonNetwork.LocalPlayer, activeState + " end");
            }

            // If was ranged pulling and pull was finished
            else if (activeState == InteractionState.RangedPulling && state == InteractionState.None)
            {
                DataLogger.Instance.LogActionData(this, PhotonNetwork.LocalPlayer, PhotonNetwork.LocalPlayer, InteractionState.RangedInteraction + " end");
            }
        }

        switch (state)
        {
        case InteractionState.None:
            previousState = InteractionState.None;
            selectedInteractionRenderer.Sprite = null;
            tracerVisibility     = VisibilityStates.AlwaysOff;
            selectionMode        = SelectionMode.None;
            interactGrab.enabled = true;
            break;

        case InteractionState.RangedPrivateBrush:
            selectedInteractionRenderer.Sprite = privateBrushSprite;
            tracerVisibility     = VisibilityStates.AlwaysOn;
            interactGrab.enabled = false;
            break;

        case InteractionState.RangedSharedBrush:
            selectedInteractionRenderer.Sprite = sharedBrushSprite;
            tracerVisibility     = VisibilityStates.AlwaysOn;
            interactGrab.enabled = false;
            break;

        case InteractionState.RangedBrushing:
            break;

        case InteractionState.RangedInteraction:
            selectedInteractionRenderer.Sprite = rangedInteractionSprite;
            tracerVisibility = VisibilityStates.AlwaysOn;
            SetPointerOpacityOne();
            Set3DstickOff();
            interactGrab.enabled = true;
            break;

        case InteractionState.RangedInteracting:
            interactGrab.enabled = true;
            break;

        case InteractionState.RangedPulling:
            interactGrab.enabled = true;
            break;
        }

        activeState = state;
        Debug.Log("Ranged interaction state changed to " + state.ToString());
    }