Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 4
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.transform.TryGetComponent <Bullet>(out var plug))
     {
         if (!IsOpen)
         {
             OnChoice?.Invoke(this);
         }
         Destroy(collision.gameObject);
     }
 }
Ejemplo n.º 5
0
 public void SetOnChoiceHandler(OnChoice handler)
 {
     _choiceHandler = handler;
 }
Ejemplo n.º 6
0
 public void SetupChoiceEvent(int choiceNumber)
 {
     OnChoice?.Invoke(choiceNumber, currentTrigger);
 }
Ejemplo n.º 7
0
 private void SendAnswer()
 {
     OnChoice.Invoke(this);
 }
 public void Choose(int choice) => OnChoice?.Invoke(this, choice);
Ejemplo n.º 9
0
 public virtual void InvokeOnChoice(string input)
 {
     OnChoice?.Invoke(input);
 }