示例#1
0
        public virtual void StartIsFinished()
        {
            Initialize();
            UpdateHelpInfo();

            if (!DecisionWasPreparedAndShown)
            {
                DecisionWasPreparedAndShown = true;

                IsReadyForCommands = true;
                DecisionOwner.TakeDecision();
            }
        }
示例#2
0
        public override void Initialize()
        {
            if (decisions.Count != 0)
            {
                decisionPanel.transform.Find("InformationPanel").GetComponentInChildren <Text>().text = InfoText;

                int i = 0;
                foreach (var item in decisions)
                {
                    GameObject prefab        = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject));
                    GameObject buttonsHolder = decisionPanel.transform.Find("DecisionsPanel").gameObject;
                    GameObject button        = MonoBehaviour.Instantiate(prefab, buttonsHolder.transform);
                    button.transform.localPosition = new Vector3((i % 2 == 0) ? 5 : 200, -buttonHeight * (i / 2), 0);
                    button.name = "Button" + i;

                    button.GetComponentInChildren <Text>().text = item.Key;

                    if (tooltips.ContainsKey(item.Key))
                    {
                        Tooltips.AddTooltip(button, tooltips[item.Key]);
                    }

                    EventTrigger       trigger = button.AddComponent <EventTrigger>();
                    EventTrigger.Entry entry   = new EventTrigger.Entry();
                    entry.eventID = EventTriggerType.PointerClick;
                    entry.callback.AddListener(
                        (data) => { GameModes.GameMode.CurrentGameMode.TakeDecision(item, button); }
                        );
                    trigger.triggers.Add(entry);

                    i++;
                }
                decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(decisionPanel.GetComponent <RectTransform>().sizeDelta.x, defaultWindowHeight + ((i + 1) / 2) * buttonHeight);

                if (DecisionOwner == null)
                {
                    DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer);
                }

                if (ShowSkipButton)
                {
                    UI.ShowSkipButton();
                }

                DecisionOwner.TakeDecision();
            }
        }
        public override void Initialize()
        {
            if (decisions.Count != 0)
            {
                decisionPanel.transform.Find("InformationPanel").GetComponentInChildren <Text>().text = InfoText;

                switch (DecisionViewType)
                {
                case DecisionViewTypes.TextButtons:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        395,
                        defaultWindowHeight + ((decisions.Count + 1) / 2) * buttonHeight
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        395,
                        defaultWindowHeight + ((decisions.Count + 1) / 2) * buttonHeight
                        );
                    break;

                case DecisionViewTypes.ImageButtons:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(395, decisions.Count * 194 + (decisions.Count + 1) * 10),
                        defaultWindowHeight + 300 + 10
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        decisions.Count * 194 + (decisions.Count + 1) * 10,
                        defaultWindowHeight + 300 + 10
                        );
                    break;

                default:
                    break;
                }

                buttonsHolder.transform.localPosition = new Vector2(-buttonsHolder.GetComponent <RectTransform>().sizeDelta.x / 2, -70);

                int i = 0;
                foreach (var decision in decisions)
                {
                    GameObject prefab = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        prefab = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject));
                        break;

                    case DecisionViewTypes.ImageButtons:
                        prefab = (GameObject)Resources.Load("Prefabs/SquadBuilder/SmallCardPanel", typeof(GameObject));
                        break;

                    default:
                        break;
                    }

                    GameObject button = MonoBehaviour.Instantiate(prefab, buttonsHolder.transform);

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        button.transform.localPosition = new Vector3((i % 2 == 0) ? 5 : 200, -buttonHeight * (i / 2), 0);

                        button.GetComponentInChildren <Text>().text = decision.Name;

                        if (decision.HasTooltip)
                        {
                            Tooltips.AddTooltip(button, decision.Tooltip);
                        }

                        EventTrigger       trigger = button.AddComponent <EventTrigger>();
                        EventTrigger.Entry entry   = new EventTrigger.Entry();
                        entry.eventID = EventTriggerType.PointerClick;
                        entry.callback.AddListener(
                            (data) => { GameModes.GameMode.CurrentGameMode.TakeDecision(decision, button); }
                            );
                        trigger.triggers.Add(entry);

                        break;

                    case DecisionViewTypes.ImageButtons:
                        button.transform.localPosition = new Vector3(10 * (i + 1) + i * 194, 0, 0);

                        SmallCardPanel script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate { GameModes.GameMode.CurrentGameMode.TakeDecision(decision, button); },
                            decision.Count
                            );

                        break;

                    default:
                        break;
                    }

                    button.name = "Button" + i;
                    i++;
                }

                if (DecisionOwner == null)
                {
                    DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer);
                }

                if (ShowSkipButton)
                {
                    UI.ShowSkipButton();
                }

                DecisionOwner.TakeDecision();
            }
        }