public virtual void AddChoiceButton(ChoiceState choice)
        {
            if (removeAllButtonsPending)
            {
                removeAllButtonsPending = false;
                RemoveAllChoiceButtons();
            }

            var choicePrefab = string.IsNullOrWhiteSpace(choice.ButtonPath) ? defaultButtonPrefab : Resources.Load <ChoiceHandlerButton>(choice.ButtonPath);
            var choiceButton = Instantiate(choicePrefab);

            choiceButton.transform.SetParent(buttonsContainer, false);
            choiceButton.Initialize(choice);
            choiceButton.OnButtonClicked += () => OnChoice?.Invoke(choice);

            if (choice.OverwriteButtonPosition)
            {
                choiceButton.transform.localPosition = choice.ButtonPosition;
            }

            choiceButtons.Add(choiceButton);

            if (focusChoiceButtons && EventSystem.current)
            {
                EventSystem.current.SetSelectedGameObject(choiceButton.gameObject);
            }
        }
Example #2
0
        /// <summary>
        /// pick a plan
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void submit_Click(object sender, EventArgs e)
        {
            int planNum = this.Ctrl.PickPlan((string)this.plans.SelectedItem);

            if (OnChoice != null)
            {
                OnChoice.Invoke(this, new ChoiceArgs(planNum));
            }
            this.Close();
        }
        public virtual void AddChoiceButton(ChoiceState choice)
        {
            if (removeAllButtonsPending)
            {
                removeAllButtonsPending = false;
                RemoveAllChoiceButtons();
            }

            if (choiceButtons.Any(b => b.ChoiceState.Id == choice.Id))
            {
                return;                                                        // Could happen on rollback.
            }
            var choicePrefab = string.IsNullOrWhiteSpace(choice.ButtonPath) ? defaultButtonPrefab : Resources.Load <ChoiceHandlerButton>(choice.ButtonPath);

            if (!choicePrefab)
            {
                Debug.LogError($"Failed to add `{choice.ButtonPath}` choice button. Make sure the button prefab is stored in a `Resources` folder of the project.");
                return;
            }
            var choiceButton = Instantiate(choicePrefab);

            choiceButton.transform.SetParent(buttonsContainer, false);
            choiceButton.Initialize(choice);
            choiceButton.OnButtonClicked += () => OnChoice?.Invoke(choice);

            if (backlogUI != null)
            {
                choiceButton.OnButtonClicked += () => backlogUI.AddChoice(choiceButtons
                                                                          .Select(b => new Tuple <string, bool>(b.ChoiceState.Summary, b.ChoiceState.Id == choice.Id)).ToList());
            }

            if (choice.OverwriteButtonPosition)
            {
                choiceButton.transform.localPosition = choice.ButtonPosition;
            }

            choiceButtons.Add(choiceButton);

            if (focusChoiceButtons)
            {
                switch (FocusModeType)
                {
                case FocusMode.Visibility:
                    if (EventSystem.current)
                    {
                        EventSystem.current.SetSelectedGameObject(choiceButton.gameObject);
                    }
                    break;

                case FocusMode.Navigation:
                    FocusOnNavigation = choiceButton.gameObject;
                    break;
                }
            }
        }
Example #4
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.transform.TryGetComponent <Bullet>(out var plug))
     {
         if (!IsOpen)
         {
             OnChoice?.Invoke(this);
         }
         Destroy(collision.gameObject);
     }
 }
Example #5
0
 public void SetupChoiceEvent(int choiceNumber)
 {
     OnChoice?.Invoke(choiceNumber, currentTrigger);
 }
Example #6
0
 private void SendAnswer()
 {
     OnChoice.Invoke(this);
 }
 public void Choose(int choice) => OnChoice?.Invoke(this, choice);
Example #8
0
 public virtual void InvokeOnChoice(string input)
 {
     OnChoice?.Invoke(input);
 }