private void ShowActionObject(Base.ActionObject actionObject) {
        MenuManager.Instance.ActionObjectSettingsMenu.Close();
        actionObject.ShowMenu();
        Base.Scene.Instance.SetSelectedObject(actionObject.gameObject);
        actionObject.SendMessage("Select");

    }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates action point GameObject in ActionObjects.ActionPoints dict based on the data present in IO.Swagger.Model.ActionPoint Data.
        /// </summary>
        /// <param name="project"></param>
        public void UpdateActionPoints(IO.Swagger.Model.Project project)
        {
            List <string> currentAP                 = new List <string>();
            List <string> currentActions            = new List <string>();
            Dictionary <string, string> connections = new Dictionary <string, string>();



            foreach (IO.Swagger.Model.ProjectActionPoint projectActionPoint in project.ActionPoints)
            {
                // if action point exist, just update it
                if (ActionPoints.TryGetValue(projectActionPoint.Id, out ActionPoint actionPoint))
                {
                    actionPoint.ActionPointBaseUpdate(projectActionPoint);
                }
                // if action point doesn't exist, create new one
                else
                {
                    ActionObject actionObject = null;
                    if (projectActionPoint.Parent != null)
                    {
                        ActionObjects.TryGetValue(projectActionPoint.Parent, out actionObject);
                    }
                    //TODO: update spawn action point to not need action object
                    actionPoint = SpawnActionPoint(projectActionPoint, actionObject);
                }

                // update actions in current action point
                (List <string>, Dictionary <string, string>)updateActionsResult = actionPoint.UpdateActionPoint(projectActionPoint);
                currentActions.AddRange(updateActionsResult.Item1);
                // merge dictionaries
                connections = connections.Concat(updateActionsResult.Item2).GroupBy(i => i.Key).ToDictionary(i => i.Key, i => i.First().Value);

                actionPoint.UpdatePositionsOfPucks();

                currentAP.Add(actionPoint.Data.Id);
            }



            UpdateActionConnections(project.ActionPoints, connections);

            // Remove deleted actions
            foreach (string actionId in GetAllActionsDict().Keys.ToList <string>())
            {
                if (!currentActions.Contains(actionId))
                {
                    RemoveAction(actionId);
                }
            }

            // Remove deleted action points
            foreach (string actionPointId in GetAllActionPointsDict().Keys.ToList <string>())
            {
                if (!currentAP.Contains(actionPointId))
                {
                    RemoveActionPoint(actionPointId);
                }
            }
        }
Ejemplo n.º 3
0
        public ActionObject SpawnActionObject(string id, string type, bool updateScene = true, string name = "")
        {
            if (!ActionsManager.Instance.ActionObjectMetadata.TryGetValue(type, out ActionObjectMetadata aom))
            {
                return(null);
            }
            GameObject obj;

            if (aom.Robot)
            {
                obj = Instantiate(RobotPrefab, ActionObjectsSpawn.transform);
            }
            else
            {
                switch (type)
                {
                case "Box":
                    obj = Instantiate(BoxPrefab, ActionObjectsSpawn.transform);
                    break;

                case "Box2":
                    obj = Instantiate(BoxPrefab, ActionObjectsSpawn.transform);
                    break;

                case "Tester":
                    obj = Instantiate(TesterPrefab, ActionObjectsSpawn.transform);
                    break;

                case "Workspace":
                    obj = Instantiate(WorkspacePrefab, ActionObjectsSpawn.transform);
                    break;

                default:
                    obj = Instantiate(UnknownPrefab, ActionObjectsSpawn.transform);
                    break;
                }
            }

            ActionObject actionObject = obj.GetComponentInChildren <ActionObject>();

            if (name == "")
            {
                name = GetFreeAOName(type);
            }

            actionObject.InitActionObject(id, type, obj.transform.localPosition, obj.transform.localRotation, id, aom);

            // Add the Action Object into scene reference
            ActionObjects.Add(id, actionObject);
            if (aom.Robot)
            {
                actionObject.LoadEndEffectors();
            }

            return(actionObject);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates action GameObjects in ActionObjects dict based on the data present in IO.Swagger.Model.Scene Data.
        /// </summary>
        public void UpdateActionObjects()
        {
            List <string> currentAO = new List <string>();

            foreach (IO.Swagger.Model.SceneObject aoSwagger in Data.Objects)
            {
                ActionObject actionObject = SpawnActionObject(aoSwagger.Id, aoSwagger.Type, false, aoSwagger.Name);
                actionObject.ActionObjectUpdate(aoSwagger, ActionObjectsVisible, ActionObjectsInteractive);
                currentAO.Add(aoSwagger.Id);
            }
        }
Ejemplo n.º 5
0
 public bool TryGetActionObjectByName(string name, out ActionObject actionObjectOut)
 {
     foreach (ActionObject actionObject in ActionObjects.Values)
     {
         if (actionObject.GetName() == name)
         {
             actionObjectOut = actionObject;
             return(true);
         }
     }
     actionObjectOut = null;
     return(false);
 }
Ejemplo n.º 6
0
    public async void DeleteActionObject()
    {
        IO.Swagger.Model.RemoveFromSceneResponse response = await Base.GameManager.Instance.RemoveFromScene(CurrentObject.Data.Id);

        if (!response.Result)
        {
            Notifications.Instance.ShowNotification("Failed to remove object " + CurrentObject.Data.Name, response.Messages[0]);
            return;
        }
        CurrentObject = null;
        ConfirmationDialog.Close();
        MenuManager.Instance.ActionObjectMenuSceneEditor.Close();
    }
Ejemplo n.º 7
0
 public override async Task <bool> Show(InteractiveObject obj, bool lockTree)
 {
     if (!await base.Show(obj, false))
     {
         return(false);
     }
     if (obj is ActionObject actionObject)
     {
         CurrentObject = actionObject;
         UpdateMenu();
         EditorHelper.EnableCanvasGroup(CanvasGroup, true);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
 public async void InitFromActionObject(Base.ActionObject actionObject)
 {
     /*InitDialog(actionObject.ActionProvider, actionObject.Metadata, actionObject.ActionPoint);
      * actionParameters = await Base.Action.InitParameters(actionProvider.GetProviderId(), actionObject.Parameters.Values.ToList(), DynamicContent, OnChangeParameterHandler, DynamicContentLayout, CanvasRoot);
      * nameInput.SetValue(Base.ProjectManager.Instance.GetFreeActionName(actionObject.Data.Name));*/
 }
 public void UpdateEndEffectorList(Base.ActionObject robot)
 {
     Dropdown.Dropdown.dropdownItems.Clear();
     PutData(robot.EndEffectors);
 }
Ejemplo n.º 10
0
    public async void UpdateMenu()
    {
        scrollableContent.GetComponent <VerticalLayoutGroup>().enabled = true;

        Base.ActionPoint actionPoint;
        if (CurrentActionPoint == null)
        {
            return;
        }
        else
        {
            actionPoint = CurrentActionPoint.GetComponent <Base.ActionPoint>();
        }

        foreach (RectTransform o in dynamicContent.GetComponentsInChildren <RectTransform>())
        {
            if (o.gameObject.tag != "Persistent")
            {
                Destroy(o.gameObject);
            }
        }
        SetHeader(actionPoint.Data.Name);
        if (actionPoint.Parent != null)
        {
            ActionObjectType.text = actionPoint.Parent.GetName();
        }
        else
        {
            ActionObjectType.text = "Global action point";
        }

        Dictionary <IActionProvider, List <Base.ActionMetadata> > actionsMetadata;

        if (actionPoint.Parent == null)
        {
            actionsMetadata = Base.ActionsManager.Instance.GetAllFreeActions();
        }
        else
        {
            Base.ActionObject parentActionObject = actionPoint.Parent.GetActionObject();
            if (parentActionObject == null)
            {
                actionsMetadata = Base.ActionsManager.Instance.GetAllFreeActions();
            }
            else
            {
                actionsMetadata = Base.ActionsManager.Instance.GetAllActionsOfObject(parentActionObject);
            }
        }

        foreach (KeyValuePair <IActionProvider, List <Base.ActionMetadata> > keyval in actionsMetadata)
        {
            CollapsableMenu collapsableMenu = Instantiate(CollapsablePrefab, dynamicContent.transform).GetComponent <CollapsableMenu>();
            collapsableMenu.SetLabel(keyval.Key.GetProviderName());
            collapsableMenu.Collapsed = true;

            foreach (Base.ActionMetadata am in keyval.Value)
            {
                ActionButton btn = Instantiate(Base.GameManager.Instance.ButtonPrefab, collapsableMenu.Content.transform).GetComponent <ActionButton>();
                btn.transform.localScale = new Vector3(1, 1, 1);
                btn.SetLabel(am.Name);
                if (am.Disabled)
                {
                    CreateTooltip(am.Problem, btn);
                    btn.Button.interactable = false;
                }
                else if (!string.IsNullOrEmpty(am.Description))
                {
                    CreateTooltip(am.Description, btn);
                }

                btn.Button.onClick.AddListener(() => ShowAddNewActionDialog(am.Name, keyval.Key));
            }
        }

        UpdateLockedBtns(CurrentActionPoint.Locked);
        if (CurrentActionPoint.Parent == null)
        {
            UntieBtn.onClick.RemoveAllListeners();
            UntieBtn.onClick.AddListener(() => AssignToParent());
            UntieBtnTooltip.ShowAlternativeDescription();
        }
        else
        {
            UntieBtn.onClick.RemoveAllListeners();
            UntieBtn.onClick.AddListener(() => ShowUntieActionPointDialog());
            UntieBtnTooltip.ShowDefaultDescription();
        }

        RemoveBtn.SetInteractivity(await GameManager.Instance.RemoveActionPoint(CurrentActionPoint.Data.Id, true));
        ExpandBtn.gameObject.SetActive(CurrentActionPoint.ActionsCollapsed);
        CollapseBtn.gameObject.SetActive(!CurrentActionPoint.ActionsCollapsed);
    }