Example #1
0
    // Reset the state of interactable with given siteID and spotID
    public static string resetInteractable(string input)
    {
        string[] stringInputs = input.Split(null);
        if (stringInputs.Length <= 2)
        {
            return("Invalid parameters: please enter a siteID and spotID.");
        }
        int[] intInput  = new int[2];
        bool  validInts = true;

        for (int i = 0; i < intInput.Length; i++)
        {
            validInts = int.TryParse(stringInputs[i], out intInput[i]) && validInts;
        }

        if (!validInts)
        {
            return("Invalid parameters: please use integers");
        }

        foreach (Interactable item in InteractableManager.InteractableList)
        {
            if (item.ID.siteID == intInput[0] && item.ID.spotID == intInput[1])
            {
                item.ActionIndex = 0;
                InteractableState state = item.stateData.states[item.ActionIndex];
                state.enterState(item);
                //item.HighlightInteractable(true, true);
                item.interactableUI.SetActionUI(item.ActionIndex);
                return("resetting interactable at site: " + intInput[0] + " and spot: " + intInput[1]);
            }
        }

        return("Could not find interactable at site: " + intInput[0] + " and spot: " + intInput[1]);
    }
Example #2
0
 public void doAction(int actionIndex)
 {
     if (stateData == null)
     {
         Debug.Log(this.name + " Error: StateData is null");
         return;
     }
     else if (stateData.states.Count == 0)
     {
         Debug.Log(this.name + " Error: States is empty");
         return;
     }
     else
     {
         InteractableState state = stateData.states[actionIndex];
         state.enterState(this);
     }
 }
Example #3
0
    /// <summary> Set interactable state with given action index </summary>
    /// <param name="actionIndex"> Action Index </param>
    public void SetPreviewAction(int actionIndex)
    {
        if (previewChild == null)
        {
            return;
        }

        Interactable interactable = previewChild.GetComponent <Interactable>();

        if (interactable == null)
        {
            return;
        }
        if (interactable.stateData == null)
        {
            return;
        }

        InteractableState state = interactable.stateData.states[actionIndex];

        state.enterState(interactable, false);

        SetLayerRecursively(previewChild, 0);
    }