Пример #1
0
        public JsonResult <object> PerformAction(string sessionId, string elementId, ElementAction elementAction)
        {
            var session = GetSession(sessionId);
            var result  = session.PerformAction(new Guid(elementId), elementAction);

            return(Json(result));
        }
    public static void Add(ElementAction itemAction)
    {
        GameObject go = new GameObject(itemAction + " Duration");

        durationGameObjects.Add(go);
        go.AddComponent <DurationManager>().Init(itemAction);
    }
Пример #3
0
        private void DeleteAction()
        {
            if (grdDataView.SelectedRowsCount <= 0)
            {
                MessageBox.Show("You must select the action you want to delete.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                if (grdDataView.GetRow(grdDataView.GetSelectedRows()[0]) is ElementAction action)
                {
                    if (MessageBox.Show("Are you sure you want to delete the action " + action.Description + "?",
                                        Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        return;
                    }

                    ElementAction.Delete(action.ID);
                    this.OwnerElement.Actions.Remove(action);

                    this.Refresh();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("ERROR removing data: " + ex.Message,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
 /// <summary>
 /// Visits all elements and perform the action
 /// </summary>
 /// <param name="jaggedArray">Jagged array</param>
 /// <param name="action">Action delegate</param>
 public static void VisitElements(IEnumerable jaggedArray, ElementAction action)
 {
     foreach (object elt in ElementIterator(jaggedArray))
     {
         action(elt);
     }
 }
Пример #5
0
        protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext)
        {
            string url = this.UrlDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext);

            this.External = url.Contains("//");

            if (!External)
            {
                url = UrlUtils.ResolvePublicUrl(url);
            }

            CustomUrlActionNodeActionToken actionToken = new CustomUrlActionNodeActionToken(
                url,
                this.External,
                (this.External ? "externalview" : "documentview"),
                this.ViewLabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext),
                this.ViewToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext),
                this.Serialize(),
                this.PermissionTypes);

            ElementAction elementAction = new ElementAction(new ActionHandle(actionToken))
            {
                VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext)
            };

            actionAdder(elementAction);
        }
Пример #6
0
        private void CmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                // Get the properties
                this.Element.Name = txtName.Text.Trim();

                // Store the element properties
                Element.Save(this.Element);

                // Save the connections (inputs and outputs)
                foreach (AccessoryDecoderConnection output in this.Element.AccessoryConnections)
                {
                    AccessoryDecoderConnection.Save(output);
                }

                // Save the actions
                foreach (ElementAction action in this.Element.Actions)
                {
                    ElementAction.Save(action);
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR storing data:" + Environment.NewLine + Environment.NewLine + ex.Message,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #7
0
        private void EditAction()
        {
            if (grdDataView.SelectedRowsCount <= 0)
            {
                MessageBox.Show("You must select the action you want to edit.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                ElementAction action = grdDataView.GetRow(grdDataView.GetSelectedRows()[0]) as ElementAction;
                if (action != null)
                {
                    ActionEditorView form = new ActionEditorView(this.OwnerElement, action);
                    form.ShowDialog(this);

                    if (form.DialogResult == DialogResult.OK)
                    {
                        this.Refresh();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("ERROR loading data: " + ex.Message,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        public IEnumerable <ElementAction> GetActions(EntityToken entityToken)
        {
            var dataEntityToken = entityToken as DataEntityToken;

            if (dataEntityToken == null)
            {
                return(NoActions);
            }

            if (dataEntityToken.InterfaceType != typeof(IXsltFunction))
            {
                return(NoActions);
            }

            var action = new ElementAction(new ActionHandle(new ConvertFunctionActionToken()))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = "Convert to Razor",
                    ToolTip        = "Creates a new razor function with the same name and parameters while renaming the existing xsl function",
                    Icon           = ActionIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Other,
                        IsInFolder  = false,
                        IsInToolbar = true,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            };

            return(new [] { action });
        }
Пример #9
0
        public ActivateRouteActionControl(ElementAction action)
        {
            InitializeComponent();

            this.Action = action;

            this.ListRoutes(this.Action.IntegerParameter1);
        }
Пример #10
0
        public ActionResult AddOrUpdateElementActions()
        {
            String json = Request["data"];
            var    rows = (ArrayList)MiniJSON.Decode(json);

            foreach (Hashtable row in rows)
            {
                var id = new Guid(row["Id"].ToString());
                //根据记录状态,进行不同的增加、删除、修改操作
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                if (state == "modified" || state == "") //更新:_state为空或modified
                {
                    var inputModel = new ElementAction()
                    {
                        Id        = new Guid(row["Id"].ToString()),
                        ElementId = new Guid(row["ElementId"].ToString()),
                        ActionId  = new Guid(row["ActionId"].ToString()),
                        IsAudit   = row["IsAudit"].ToString(),
                        IsAllowed = row["IsAllowed"].ToString()
                    };
                    ElementDescriptor element;
                    AcDomain.NodeHost.Ontologies.TryGetElement(inputModel.ElementId, out element);
                    ElementAction entity = null;
                    if (element != null)
                    {
                        entity = new ElementAction
                        {
                            ActionId  = inputModel.ActionId,
                            IsAllowed = inputModel.IsAllowed,
                            IsAudit   = inputModel.IsAudit,
                            ElementId = element.Element.Id,
                            Id        = inputModel.Id
                        };
                        AcDomain.PublishEvent(new ElementActionUpdatedEvent(AcSession, entity));
                    }
                    else
                    {
                        entity = new ElementAction
                        {
                            Id        = inputModel.Id,
                            ElementId = inputModel.ElementId,
                            ActionId  = inputModel.ActionId,
                            IsAudit   = inputModel.IsAudit,
                            IsAllowed = inputModel.IsAllowed
                        };
                        AcDomain.PublishEvent(new ElementActionAddedEvent(AcSession, entity));
                    }
                    AcDomain.CommitEventBus();
                }
            }

            return(this.JsonResult(new ResponseData {
                success = true
            }));
        }
Пример #11
0
 public RoWebElementEDA(TestStep elementTestStep)
 {
     _elementAction      = elementTestStep.WebAction.Action as ElementAction;
     ComArgs.SigTestStep = elementTestStep;
     //提取超时
     if (_elementAction != null)
     {
         TimeSpan timeSpan = TimeSpan.FromSeconds(_elementAction.Timeout);
         _webDriverWait = new WebDriverWait(ComArgs.WebTestDriver, timeSpan);
     }
 }
Пример #12
0
        public void GenericTemplateTest()
        {
            var buttons = new List <IButton>();

            buttons.Add(new PostbackButton()
            {
                Title   = "Button 1",
                Payload = "webhook_value_1"
            });

            buttons.Add(new PostbackButton()
            {
                Title   = "Button 2",
                Payload = "webhook_value_2"
            });

            var defaultAction = new ElementAction()
            {
                Url = "https://m.me/",
            };

            var elements = new List <GenericTemplate.Element>();

            elements.Add(new GenericTemplate.Element()
            {
                Title         = "Title 1",
                Subtitle      = "Subtitle 1",
                ImageUrl      = "",
                DefaultAction = defaultAction,
                Buttons       = buttons
            });

            elements.Add(new GenericTemplate.Element()
            {
                Title    = "Title 2",
                Subtitle = "Subtitle 2",
                ImageUrl = "",
                Buttons  = buttons
            });

            var attachment = new Attachment <GenericTemplate>()
            {
                Payload = new GenericTemplate()
                {
                    Elements = elements
                }
            };

            //client.SendAttachment<LogInButton>("asd", new LogInButton());

            string result = client.SendAttachment <GenericTemplate>(UserId.ToString(), attachment).Result.Id;

            Trace.WriteLine($"Message Id: {result}");
        }
Пример #13
0
        /// <summary>
        /// Shortcut for adding an element action.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="name"></param>
        /// <param name="execute"></param>
        /// <param name="canExecute"></param>
        /// <returns></returns>
        public static IElementAction AddAction(this Element element, string name, Action execute, Func<bool> canExecute = null)
        {
            if (element == null) throw new ArgumentNullException(nameof(element));
            if (execute == null) throw new ArgumentNullException(nameof(execute));

            var action = new ElementAction(name, execute, canExecute);

            element.AddAction(action);

            return action;
        }
Пример #14
0
 private void grdDataView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 {
     if (e.Column == grdDataView.Columns[1])
     {
         ElementAction action = grdDataView.GetRow(e.RowHandle) as ElementAction;
         if (action != null)
         {
             StudioContext.UI.DrawRowIcon(action.Icon, e);
         }
     }
 }
Пример #15
0
        /// <summary>
        /// Send request to perform action under element
        /// </summary>
        /// <param name="element"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        internal static object PerformAction(WinElement element, ElementAction action)
        {
            using (var httpClient = new HttpClient())
            {
                var json = JsonConvert.SerializeObject(action);
                var data = new StringContent(json, Encoding.UTF8, "application/json");

                var responseMessage = httpClient.PostAsync($"{element.Driver.Uri}/session/{element.Driver.Guid}/element/{element.Guid}/action", data).Result;
                var result          = responseMessage.Content.ReadAsStringAsync().Result;
                return(result);
            }
        }
Пример #16
0
 /// <summary>
 /// Update an item into the project.
 /// </summary>
 /// <param name="item">Item to update.</param>
 public void Update(ElementAction item)
 {
     try
     {
         // Create the new element into the DB
         OTCProject.LayoutManager.ElementActionDAO.Update(item);
     }
     catch (Exception ex)
     {
         Logger.LogError(this, ex);
         throw;
     }
 }
Пример #17
0
        private void AddAccessoryAction()
        {
            ElementAction action = new ElementAction();

            action.Element = this.OwnerElement;
            action.Type    = ElementAction.ActionTypes.SetAccessoryStatus;

            ActionEditorView form = new ActionEditorView(this.OwnerElement, action);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                this.Refresh();
            }
        }
Пример #18
0
    public static void ForEach <T>(this IEnumerable <T> elements, ElementAction <T> action)
    {
        IEnumerator <T> enumerator = elements.GetEnumerator();
        bool            isFirst    = true;
        bool            hasNext    = enumerator.MoveNext();
        int             index      = 0;

        while (hasNext)
        {
            T current = enumerator.Current;
            hasNext = enumerator.MoveNext();
            action(current, new ElementInfo(index, isFirst, !hasNext));
            isFirst = false;
            index++;
        }
    }
Пример #19
0
        private void AddRouteAction()
        {
            ElementAction action = new ElementAction();

            action.Element = this.OwnerElement;
            action.Type    = ElementAction.ActionTypes.ActivateRoute;

            ActionEditorView form = new ActionEditorView(this.OwnerElement, action);

            form.ShowDialog(this);

            if (form.DialogResult == DialogResult.OK)
            {
                this.Refresh();
            }
        }
Пример #20
0
        /// <summary>
        /// Delete the specified item from the project.
        /// </summary>
        /// <param name="item">Item to remove.</param>
        public void Remove(ElementAction item)
        {
            try
            {
                // Create the new element into the DB
                OTCProject.LayoutManager.ElementActionDAO.Delete(item.ID);

                // Add the new element into the in-memory project
                item.Element.Actions.Remove(item);
                this.ElementActions.Add(item);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);
                throw;
            }
        }
Пример #21
0
        /// <summary>
        /// Shortcut for adding an element action.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="name"></param>
        /// <param name="execute"></param>
        /// <param name="canExecute"></param>
        /// <returns></returns>
        public static IElementAction AddAction(this Element element, string name, Action execute, Func <bool> canExecute = null)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }
            if (execute == null)
            {
                throw new ArgumentNullException(nameof(execute));
            }

            var action = new ElementAction(name, execute, canExecute);

            element.AddAction(action);

            return(action);
        }
Пример #22
0
        protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext)
        {
            ActionToken actionToken = new MessageBoxActionNodeActionToken(
                this.TitleDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext),
                this.MessageDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext),
                this.Serialize(),
                this.PermissionTypes
                );

            ElementAction elementAction = new ElementAction(new ActionHandle(actionToken))
            {
                VisualData = this.CreateActionVisualizedData(dynamicValuesHelperReplaceContext)
            };

            elementAction.VisualData.ActionLocation = this.Location;

            actionAdder(elementAction);
        }
Пример #23
0
        private void WaitForControlToExistAndDoAction(IWebElement element, ElementAction elementAction)
        {
            bool elementExists = false;
            int  i             = 0;
            bool useJS         = true;

            while (!elementExists)
            {
                try
                {
                    switch (elementAction)
                    {
                    case ElementAction.Clear:
                        element.Clear();
                        return;

                    case ElementAction.Click:
                        if (!useJS)     //we try using normal method to click once and JS the next time. useJS bool value toggles (see catch block code)
                        {
                            element.Click();
                        }
                        else
                        {
                            IJavaScriptExecutor executor = (IJavaScriptExecutor)this.CurrentBrowser.WebDriver;
                            executor.ExecuteScript("arguments[0].click();", element);
                        }
                        return;
                    }
                }
                catch (NoSuchElementException ex)
                {
                    elementExists = false;
                    useJS         = !useJS;
                    System.Threading.Thread.Sleep(500);
                    if (i > 20) //looks for 10 seconds
                    {
                        throw new NoSuchElementException();
                    }
                    i++;
                }
            }
        }
Пример #24
0
        internal object PerformAction(Guid elementId, ElementAction action)
        {
            var element = Elements[elementId];

            switch (action.ActionType)
            {
            case ActionType.Invoke:
                Invoke(element);
                break;

            case ActionType.Click:
                Click(element);
                break;

            case ActionType.Select:
                Select(element);
                break;

            case ActionType.DoDefaultAction:
                DoDefaultAction(element);
                break;

            case ActionType.GetToggleState:
                return(GetToggleState(element));

            case ActionType.Expand:
                Expand(element);
                break;

            case ActionType.Collapse:
                Collapse(element);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(action), action, null);
            }

            return(null);
        }
Пример #25
0
        private void cmdOK_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtDescription.Text))
            {
                MessageBox.Show("You must provide a valid descriptive name for the current action.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (cboEvent.SelectedItem == null)
            {
                MessageBox.Show("You must select the event you want to execute the current action.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (!this.Editor.CheckData())
            {
                return;
            }

            try
            {
                this.Action.Element         = this.OwnerBlock;
                this.Action.Description     = txtDescription.Text.Trim();
                this.Action.Event           = this.SelectedEvent;
                this.Action.ConditionStatus = this.SelectedStatusFilter;

                ElementAction.Save(this.Action);

                this.OwnerBlock.Actions.Add(this.Action);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR storing action: " + ex.Message,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #26
0
 public ElementActionUpdatedEvent(IAcSession acSession, ElementAction source)
     : base(acSession, source)
 {
     this.IsAllowed = source.IsAllowed;
     this.IsAudit   = source.IsAudit;
 }
Пример #27
0
        /// <exclude />
        public List <ElementAction> GetActions(IData data, Type elementProviderType)
        {
            if (!(data is IPublishControlled) ||
                !data.DataSourceId.DataScopeIdentifier.Equals(DataScopeIdentifier.Administrated))
            {
                return(new List <ElementAction>());
            }

            if (data is ILocalizedControlled && !UserSettings.ActiveLocaleCultureInfo.Equals(data.DataSourceId.LocaleScope))
            {
                return(new List <ElementAction>());
            }

            var publishControlled = (IPublishControlled)data;

            IList <string> visualTrans;

            if (!_visualTransitions.TryGetValue(publishControlled.PublicationStatus, out visualTrans))
            {
                throw new InvalidOperationException($"Unknown publication state '{publishControlled.PublicationStatus}'");
            }

            var clientActions = visualTrans.Select(newState => _visualTransitionsActions[newState]()).ToList();


            IData publicData = DataFacade.GetDataFromOtherScope(data, DataScopeIdentifier.Public, true, false).FirstOrDefault();

            if (publicData != null)
            {
                var unpublishAction = new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Unpublish)
                {
                    DoIgnoreEntityTokenLocking = true
                }))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "Unpublish"),
                        ToolTip        = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "UnpublishToolTip"),
                        Icon           = GenericPublishProcessController.Unpublish,
                        Disabled       = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType  = ActionType.Other,
                            IsInFolder  = false,
                            IsInToolbar = true,
                            ActionGroup = WorkflowActionGroup
                        }
                    }
                };

                clientActions.Add(unpublishAction);



                if (publishControlled.PublicationStatus == Draft)
                {
                    if (ProcessControllerAttributesFacade.IsActionIgnored(elementProviderType, GenericPublishProcessControllerActionTypeNames.UndoUnpublishedChanges) == false)
                    {
                        ActionToken actionToken;

                        IActionTokenProvider actionTokenProvider = ProcessControllerAttributesFacade.GetActionTokenProvider(elementProviderType, GenericPublishProcessControllerActionTypeNames.UndoUnpublishedChanges);
                        if (actionTokenProvider != null)
                        {
                            actionToken = actionTokenProvider.GetActionToken(GenericPublishProcessControllerActionTypeNames.UndoUnpublishedChanges, data);
                        }
                        else
                        {
                            actionToken = new UndoPublishedChangesActionToken();
                        }

                        var undoPublishedChangesAction = new ElementAction(new ActionHandle(actionToken))
                        {
                            VisualData = new ActionVisualizedData
                            {
                                Label          = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "UndoPublishedChanges"),
                                ToolTip        = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "UndoPublishedChangesToolTip"),
                                Icon           = GenericPublishProcessController.UndoUnpublishedChanges,
                                Disabled       = false,
                                ActionLocation = new ActionLocation
                                {
                                    ActionType  = ActionType.Other,
                                    IsInFolder  = false,
                                    IsInToolbar = true,
                                    ActionGroup = WorkflowActionGroup
                                }
                            }
                        };

                        clientActions.Add(undoPublishedChangesAction);
                    }
                }
            }

            return(clientActions);
        }
Пример #28
0
        public ActionResult AddOrUpdateElementActions()
        {
            String json = Request["data"];
            var rows = (ArrayList)MiniJSON.Decode(json);
            foreach (Hashtable row in rows)
            {
                var id = new Guid(row["Id"].ToString());
                //根据记录状态,进行不同的增加、删除、修改操作
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                if (state == "modified" || state == "") //更新:_state为空或modified
                {
                    var inputModel = new ElementAction()
                    {
                        Id = new Guid(row["Id"].ToString()),
                        ElementId = new Guid(row["ElementId"].ToString()),
                        ActionId = new Guid(row["ActionId"].ToString()),
                        IsAudit = row["IsAudit"].ToString(),
                        IsAllowed = row["IsAllowed"].ToString()
                    };
                    ElementDescriptor element;
                    AcDomain.NodeHost.Ontologies.TryGetElement(inputModel.ElementId, out element);
                    ElementAction entity = null;
                    if (element != null)
                    {
                        entity = new ElementAction
                        {
                            ActionId = inputModel.ActionId,
                            IsAllowed = inputModel.IsAllowed,
                            IsAudit = inputModel.IsAudit,
                            ElementId = element.Element.Id,
                            Id = inputModel.Id
                        };
                        AcDomain.PublishEvent(new ElementActionUpdatedEvent(AcSession, entity));
                    }
                    else
                    {
                        entity = new ElementAction
                        {
                            Id = inputModel.Id,
                            ElementId = inputModel.ElementId,
                            ActionId = inputModel.ActionId,
                            IsAudit = inputModel.IsAudit,
                            IsAllowed = inputModel.IsAllowed
                        };
                        AcDomain.PublishEvent(new ElementActionAddedEvent(AcSession, entity));
                    }
                    AcDomain.CommitEventBus();
                }
            }

            return this.JsonResult(new ResponseData { success = true });
        }
Пример #29
0
 public ElementActionAddedEvent(IAcSession acSession, ElementAction source)
     : base(acSession, source)
 {
 }
Пример #30
0
    public void Use(ElementAction action)
    {
        if (!this.OnCooldown && !action.OnCooldown)
        {
            MonoBehaviour[] scripts = action.activationObject.GetComponents <MonoBehaviour>();
            MonoBehaviour   script  = null;

            foreach (MonoBehaviour mb in scripts)
            {
                if (mb.GetType().ToString() == action.selectedComponentName)
                {
                    script = (MonoBehaviour)action.activationObject.GetComponent(action.selectedComponentName);
                    break;
                }
            }

            if (script != null)
            {
                //Methods
                if (action.selectedOption == 0)
                {
                    action.cachedMethod = script.GetType().GetMethod(action.activationMethodName);

                    List <object> parameterList = new List <object>();

                    //Manage Parameters
                    if (action.sendThisItem)
                    {
                        parameterList.Add(this);
                    }
                    if (action.stringParameters.Count > 0)
                    {
                        action.stringParameters.ForEach(x => parameterList.Add(x));
                    }

                    if (parameterList.Count > 0)
                    {
                        action.cachedMethod.Invoke(script, parameterList.ToArray());
                    }
                    else
                    {
                        action.cachedMethod.Invoke(script, null);
                    }
                }
                //Fields
                else if (action.selectedOption == 1)
                {
                    action.cachedField = script.GetType().GetField(action.selectedFieldName);

                    if (action.cachedField != null)
                    {
                        if (action.cachedField.GetValue(script) is int)
                        {
                            int intVal = int.Parse(action.fieldValue);
                            int oldVal = (int)action.cachedField.GetValue(script);
                            action.cachedField.SetValue(script, oldVal + intVal);

                            if (action.hasDuration)
                            {
                                DurationManager.Add(action);
                            }
                        }
                        else if (action.cachedField.GetValue(script) is float)
                        {
                            float intVal = float.Parse(action.fieldValue);
                            float oldVal = (float)action.cachedField.GetValue(script);
                            action.cachedField.SetValue(script, oldVal + intVal);

                            if (action.hasDuration)
                            {
                                DurationManager.Add(action);
                            }
                        }
                        else if (action.cachedField.GetValue(script) is double)
                        {
                            double intVal = double.Parse(action.fieldValue);
                            double oldVal = (double)action.cachedField.GetValue(script);
                            action.cachedField.SetValue(script, oldVal + intVal);

                            if (action.hasDuration)
                            {
                                DurationManager.Add(action);
                            }
                        }
                    }
                }

                //Order cooldowntimes
                List <CooldownSettings> sortedList = action.cooldownSettings.OrderByDescending(o => o.cooldownTime).ToList();

                foreach (CooldownSettings cds in sortedList)
                {
                    //This action
                    if (cds.options[cds.selOption] == "This Action")
                    {
                        if (action.cooldownGO != null)
                        {
                            MonoBehaviour.Destroy(action.cooldownGO);
                        }

                        GameObject go = new GameObject(name + " Cooldown");
                        action.cooldownGO = go.AddComponent <CooldownManager>();
                        action.cooldownGO.Init(action, cds);

                        if (sortedList.IndexOf(cds) > 0)
                        {
                            action.cooldownGO.exclusions.Add(this);
                        }
                    }
                    else if (cds.options[cds.selOption] == "Type")
                    {
                        if (InventoryDatabase.Instance != null)
                        {
                            ElementType e = InventoryDatabase.FindElementType(cds.selectedType);

                            if (e != null)
                            {
                                if (e.cooldownGO != null)
                                {
                                    MonoBehaviour.Destroy(e.cooldownGO);
                                }

                                GameObject go = new GameObject(name + " Cooldown");
                                e.cooldownGO = go.AddComponent <CooldownManager>();
                                e.cooldownGO.Init(e, cds);

                                if (sortedList.IndexOf(cds) > 0)
                                {
                                    e.cooldownGO.exclusions.Add(this);
                                }
                            }
                        }
                    }
                    else if (cds.options[cds.selOption] == "This Element")
                    {
                        if (InventoryDatabase.Instance != null)
                        {
                            if (this.cooldownGO != null)
                            {
                                MonoBehaviour.Destroy(this.cooldownGO);
                            }

                            GameObject go = new GameObject(name + " Cooldown");
                            this.cooldownGO = go.AddComponent <CooldownManager>();
                            this.cooldownGO.Init(this, cds);

                            if (sortedList.IndexOf(cds) > 0)
                            {
                                this.cooldownGO.exclusions.Add(this);
                            }
                        }
                    }
                }

                if (action.destroyAfterUse)
                {
                    if (stack > 1)
                    {
                        stack--;
                    }
                    else
                    {
                        //Destroy this item
                        slot.inventoryElement = Empty;
                    }
                }
            }
        }
        else
        {
            Debug.Log(this.name + " is on cooldown.");
        }
    }
 public ElementActionUpdatedEvent(IAcSession acSession, ElementAction source)
     : base(acSession, source)
 {
     this.IsAllowed = source.IsAllowed;
     this.IsAudit = source.IsAudit;
 }
Пример #32
0
    void EditElement(InventoryElement inventoryElement)
    {
        if (inventoryElement != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.name = EditorGUILayout.TextField("Name", inventoryElement.name);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.description = EditorGUILayout.TextField("Description", inventoryElement.description);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.gameObject = EditorGUILayout.ObjectField("GameObject", inventoryElement.gameObject, typeof(GameObject), true) as GameObject;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.isStackable = EditorGUILayout.Toggle("Is Stackable", inventoryElement.isStackable);
            GUILayout.EndHorizontal();

            if (inventoryElement.isStackable)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(15);
                inventoryElement.maxStack = EditorGUILayout.IntField("Max Stack", inventoryElement.maxStack);
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.nameColor = EditorGUILayout.ColorField("Name Tooltip Color", inventoryElement.nameColor);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.descriptionColor = EditorGUILayout.ColorField("Description Tooltip Color", inventoryElement.descriptionColor);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.icon = EditorGUILayout.ObjectField("Icon", inventoryElement.icon, typeof(Texture), true) as Texture;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            inventoryElement.windowActionFoldout = EditorGUILayout.Foldout(inventoryElement.windowActionFoldout, "Action Management");
            GUILayout.EndHorizontal();

            if (inventoryElement.windowActionFoldout)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(30);
                actionInfoFoldout = EditorGUILayout.Foldout(actionInfoFoldout, "Info");
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Space(30);
                if (actionInfoFoldout)
                {
                    EditorGUILayout.HelpBox("When you choose an Object for an action, make sure you choose an Object in the current scene" +
                                            " if you need to work with an instance of a script. Example: If you need to affect your character's health, then " +
                                            "select the object that has the Health script in the Scene as opposed to the Assets.", MessageType.Info);
                }
                GUILayout.EndHorizontal();

                for (int m = 0; m < inventoryElement.actions.Count; m++)
                {
                    ElementAction itemAction = inventoryElement.actions[m];

                    if (itemAction != null)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(30);
                        itemAction.foldout = EditorGUILayout.Foldout(itemAction.foldout, "Action " + m.ToString());
                        if (GUILayout.Button("x"))
                        {
                            inventoryElement.actions.RemoveAt(m);
                        }
                        GUILayout.EndHorizontal();

                        itemAction.OnGUI();
                    }
                }

                GUILayout.BeginHorizontal();
                GUILayout.Space(30);
                if (GUILayout.Button("Add Action"))
                {
                    inventoryElement.actions.Add(new ElementAction());
                }
                GUILayout.EndHorizontal();
            }

            GUIStyle gs = new GUIStyle();
            gs.alignment = TextAnchor.MiddleCenter;

            GUILayout.Space(10);
            editItem.deleteFoldout = EditorGUILayout.Foldout(editItem.deleteFoldout, "Delete");

            if (editItem.deleteFoldout)
            {
                editItem.areYouSure = EditorGUILayout.Toggle("Are you sure?", editItem.areYouSure);
                if (editItem.areYouSure)
                {
                    editItem.areYouSure2 = EditorGUILayout.Toggle("Are you REALLY sure?", editItem.areYouSure2);
                    if (editItem.areYouSure2)
                    {
                        if (GUILayout.Button("Delete"))
                        {
                            GUI.FocusControl(null);
                            editState = EditState.EMPTY;

                            if (InventoryManager.Instance != null)
                            {
                                for (int i = 0; i < InventoryManager.Instance.allInventoryObjects.Count; i++)
                                {
                                    for (int m = 0; m < InventoryManager.Instance.allInventoryObjects[i].Slots.Count; m++)
                                    {
                                        if (InventoryManager.Instance.allInventoryObjects[i].Slots[m].inventoryElement.id == editItem.id)
                                        {
                                            InventoryManager.Instance.allInventoryObjects[i].Slots[m].inventoryElement = new InventoryElement();
                                        }
                                    }
                                }
                            }

                            if (InventoryDatabase.Instance != null)
                            {
                                if (editItem.id != -1)
                                {
                                    InventoryDatabase.Remove(editItem);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Пример #33
0
 public ElementActionAddedEvent(IAcSession acSession, ElementAction source)
     : base(acSession, source)
 {
 }
Пример #34
0
    void EditItemType()
    {
        if (editType != null)
        {
            editType.name         = EditorGUILayout.TextField("Name", editType.name);
            editType.tooltipColor = EditorGUILayout.ColorField("Tooltip Color", editType.tooltipColor);

            GUILayout.BeginHorizontal();
            editType.windowActionFoldout = EditorGUILayout.Foldout(editType.windowActionFoldout, "Action Management");
            GUILayout.EndHorizontal();

            if (editType.windowActionFoldout)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(15);
                actionInfoFoldout = EditorGUILayout.Foldout(actionInfoFoldout, "Info");
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Space(15);
                if (actionInfoFoldout)
                {
                    EditorGUILayout.HelpBox("When you choose an Object for an action, make sure you choose an Object in the current scene" +
                                            " if you need to work with an instance of a script. Example: If you need to affect your character's health, then " +
                                            "select the object that has the Health script in the Scene as opposed to the Assets.", MessageType.Info);
                }
                GUILayout.EndHorizontal();

                for (int m = 0; m < editType.actions.Count; m++)
                {
                    ElementAction itemAction = editType.actions[m];

                    if (itemAction != null)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(30);
                        itemAction.foldout = EditorGUILayout.Foldout(itemAction.foldout, "Action " + m.ToString());
                        if (GUILayout.Button("x", EditorStyles.miniButton))
                        {
                            editType.actions.RemoveAt(m);
                        }
                        GUILayout.EndHorizontal();

                        itemAction.OnGUI();
                    }
                }

                GUILayout.BeginHorizontal();
                GUILayout.Space(30);
                if (GUILayout.Button("Add Action"))
                {
                    editType.actions.Add(new ElementAction());
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            editType.deleteFoldout = EditorGUILayout.Foldout(editType.deleteFoldout, "Delete");

            if (editType.deleteFoldout)
            {
                editType.areYouSure = EditorGUILayout.Toggle("Are you sure?", editType.areYouSure);
                if (editType.areYouSure)
                {
                    editType.areYouSure2 = EditorGUILayout.Toggle("Are you REALLY sure?", editType.areYouSure2);
                    if (editType.areYouSure2)
                    {
                        if (GUILayout.Button("Delete"))
                        {
                            GUI.FocusControl(null);
                            editState = EditState.EMPTY;

                            InventoryDatabase.Remove(editType);
                        }
                    }
                }
            }
        }
    }