Esempio n. 1
0
        private void SetConnectionToParent(IActionPointParent parent)
        {
            // Create new Line Connection between parent AO and child AP
            GameObject c = Instantiate(SceneManager.Instance.LineConnectionPrefab);

            c.transform.parent = transform;
            LineConnection newConnection = c.GetComponent <LineConnection>();

            newConnection.targets[0] = parent.GetTransform();
            newConnection.targets[1] = this.transform;

            // add the connection to connections manager
            SceneManager.Instance.AOToAPConnectionsManager.AddConnection(newConnection);

            ConnectionToParent = newConnection;

            /*
             * // Add connection renderer into ChangeMaterialOnSelected script attached on parent AO
             * ChangeMaterialOnSelected changeMaterial;
             * changeMaterial = parent.GetGameObject().GetComponent<ChangeMaterialOnSelected>();
             *
             * // if the script is not attached on parent AO, then add it and initialize its click material
             * if (changeMaterial == null) {
             *  changeMaterial = parent.GetGameObject().AddComponent<ChangeMaterialOnSelected>();
             *  changeMaterial.ClickMaterial = ConnectionToParent.ClickMaterial;
             * }
             * changeMaterial.AddRenderer(ConnectionToParent.GetComponent<LineRenderer>());*/
        }
Esempio n. 2
0
 public void SetParent(IActionPointParent parent)
 {
     Parent = parent;
     if (parent != null)
     {
         SetConnectionToParent(parent);
     }
 }
Esempio n. 3
0
 public void InitAP(IO.Swagger.Model.ProjectActionPoint apData, float size, IActionPointParent parent = null)
 {
     Debug.Assert(apData != null);
     SetParent(parent);
     Data = apData;
     OrientationsVisible     = PlayerPrefsHelper.LoadBool("/AP/" + Data.Id + "/visible", true);
     ActionsCollapsed        = PlayerPrefsHelper.LoadBool("/AP/" + Data.Id + "/actionsCollapsed", false);
     transform.localPosition = GetScenePosition();
     SetSize(size);
     ActivateForGizmo((ControlBoxManager.Instance.UseGizmoMove && ProjectManager.Instance.AllowEdit && !MenuManager.Instance.IsAnyMenuOpened) ? "GizmoRuntime" : "Default");
 }
Esempio n. 4
0
        public void InitAP(IO.Swagger.Model.ProjectActionPoint apData, float size, IActionPointParent parent = null)
        {
            Debug.Assert(apData != null);
            SetParent(parent);
            Data = apData;
            transform.localPosition = GetScenePosition();
            SetSize(size);
            ActivateForGizmo((ControlBoxManager.Instance.UseGizmoMove == true) ? "GizmoRuntime" : "Default");
            // TODO: is this neccessary?

            /*if (Data.Orientations.Count == 0)
             *  Data.Orientations.Add(new IO.Swagger.Model.NamedOrientation(id: "default", orientation: new IO.Swagger.Model.Orientation()));*/
        }
Esempio n. 5
0
    private async Task <RequestResult> ValidateParent(object selectedParent)
    {
        IActionPointParent parent = (IActionPointParent)selectedParent;
        RequestResult      result = new RequestResult(true, "");

        if (parent.GetId() == CurrentActionPoint.GetId())
        {
            result.Success = false;
            result.Message = "Action point cannot be its own parent!";
        }

        return(result);
    }
Esempio n. 6
0
    private async void AssignToParent(object selectedObject)
    {
        IActionPointParent parent = (IActionPointParent)selectedObject;

        if (parent == null)
        {
            return;
        }
        bool result = await Base.GameManager.Instance.UpdateActionPointParent(CurrentActionPoint, parent.GetId());

        if (result)
        {
            //
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Creates new action point
    /// </summary>
    /// <param name="name">Name of the new action point</param>
    /// <param name="parentId">Id of AP parent. Global if null </param>
    private async void CreateActionPoint(string name, IActionPointParent parentId = null)
    {
        Debug.Assert(!string.IsNullOrEmpty(name));
        Debug.Assert(parentId != null);
        selectAPNameWhenCreated = name;
        bool result = await GameManager.Instance.AddActionPoint(name, parentId);

        if (result)
        {
            InputDialog.Close();
        }
        else
        {
            selectAPNameWhenCreated = "";
        }
    }
Esempio n. 8
0
 private void ChangeParent(string parentId)
 {
     if (parentId == null || parentId == "")
     {
         RemoveConnectionToParent();
         Parent      = null;
         Data.Parent = "";
         return;
     }
     try {
         IActionPointParent actionPointParent = Scene.Instance.GetActionPointParent(parentId);
         Parent      = actionPointParent;
         Data.Parent = parentId;
     } catch (KeyNotFoundException ex) {
         Debug.LogError(ex);
     }
 }
Esempio n. 9
0
 public void ActionPointAdded(ProjectActionPoint projectActionPoint)
 {
     if (projectActionPoint.Parent == null || projectActionPoint.Parent == "")
     {
         SpawnActionPoint(projectActionPoint, null);
     }
     else
     {
         try {
             IActionPointParent actionPointParent = GetActionPointParent(projectActionPoint.Parent);
             SpawnActionPoint(projectActionPoint, actionPointParent);
         } catch (KeyNotFoundException ex) {
             Debug.LogError(ex);
         }
     }
     OnActionPointsChanged?.Invoke(this, EventArgs.Empty);
     OnProjectChanged?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 10
0
    private async void AssignToParent(object selectedObject)
    {
        IActionPointParent parent = (IActionPointParent)selectedObject;

        if (parent == null)
        {
            return;
        }
        string id = "";

        id = parent.GetId();
        bool result = await Base.GameManager.Instance.UpdateActionPointParent(selectedActionPoint, id);

        if (!result)
        {
            selectedActionPoint.WriteUnlock();
        }
    }
Esempio n. 11
0
 private void ChangeParent(string parentId)
 {
     if (parentId == null || parentId == "")
     {
         RemoveConnectionToParent();
         Parent                  = null;
         Data.Parent             = "";
         transform.parent        = ProjectManager.Instance.ActionPointsOrigin.transform;
         transform.localRotation = Quaternion.identity;
         return;
     }
     try {
         IActionPointParent actionPointParent = ProjectManager.Instance.GetActionPointParent(parentId);
         Parent           = actionPointParent;
         Data.Parent      = parentId;
         transform.parent = actionPointParent.GetTransform();
     } catch (KeyNotFoundException ex) {
         Debug.LogError(ex);
     }
 }
Esempio n. 12
0
        public ActionPoint SpawnActionPoint(IO.Swagger.Model.ProjectActionPoint apData, IActionPointParent actionPointParent)
        {
            Debug.Assert(apData != null);
            GameObject AP;

            if (actionPointParent == null)
            {
                AP = Instantiate(ActionPointPrefab, ActionPointsOrigin.transform);
            }
            else
            {
                AP = Instantiate(ActionPointPrefab, actionPointParent.GetTransform());
            }

            AP.transform.localScale = new Vector3(1f, 1f, 1f);
            ActionPoint actionPoint = AP.GetComponent <ActionPoint>();

            actionPoint.InitAP(apData, APSize, actionPointParent);
            ActionPoints.Add(actionPoint.Data.Id, actionPoint);

            return(actionPoint);
        }
Esempio n. 13
0
 public override void InitAP(IO.Swagger.Model.ActionPoint apData, float size, IActionPointParent parent = null)
 {
     base.InitAP(apData, size, parent);
     ActionPointName.text = apData.Name;
 }