Пример #1
0
        public UIMainMenu()
        {
            SetWidth(ScreenManager.Instance.ScreenWidth);
            SetHeight(ScreenManager.Instance.ScreenHeight);

            ConsumesMouse = false;

            Logo = new UIImage(new SpriteAnimation(Assets.Logo, 1, 1, true))
            {
                HAlign = 0.5f,
                VAlign = 0.3f,
                Scale  = 3.5f
            };

            UITextButton startGame = new UITextButton("New Game", 200, 50);

            startGame.Text.Scale    = 1f;
            startGame.HAlign        = 0.5f;
            startGame.VAlign        = 0.8f;
            startGame.TakesPriority = true;
            startGame.OnClick      += StartGame_OnClick;

            UITextButton endGame = new UITextButton("Quit", 200, 50);

            endGame.Text.Scale    = 1f;
            endGame.HAlign        = 0.5f;
            endGame.VAlign        = 0.9f;
            endGame.TakesPriority = true;
            endGame.OnClick      += EndGame_OnClick;

            Append(startGame);
            Append(endGame);

            Append(Logo);

            UIFadeIn fadeIn = new UIFadeIn()
            {
                Opacity = 3f
            };

            UIBKBLogo logo = new UIBKBLogo
            {
                HAlign = 0.5f,
                VAlign = 0.5f,
                Scale  = 0.5f
            };

            fadeIn.Append(logo);
            fadeIn.TakesPriority = true;

            Append(fadeIn);
            logoScale = 0;
        }
Пример #2
0
    IEnumerator LoadChoices(List <Choice> _choices)
    {
        //yield return new WaitForSeconds(0.1f);
        if (_choices.Count > 0)
        {
            ChoiceObject[] prevChoices = GameObject.FindObjectsOfType <ChoiceObject>();
            Debug.Log(prevChoices.Length);
            for (int i = 0; i < _choices.Count; ++i)
            {
                Choice choice = _choices[i];

                if (silentOptions.Contains(CleanText(choice.text)))
                {
                    continue;
                }

                int        ind       = choice.index;
                GameObject choiceObj = null;

                /*
                 * foreach (ChoiceObject c in prevChoices) {
                 *      string _ss = choice.text.Trim();
                 *      Debug.Log(c.text + " != " + _ss);
                 *      if (c.text.Trim() == _ss) {
                 *              Debug.Log(":D");
                 *              choiceObj = c.gameObject;
                 *              FadeElement __fade = c.GetComponent<FadeElement>();
                 *              if (__fade) {__fade.target = 1;}
                 *              Debug.Log(c.gameObject);
                 *              //Destroy(choiceObj.GetComponent<Button>());
                 *              //choiceObj.AddComponent<Button>();
                 *              if (!choices.Contains(c.transform)) {choices.Add(c.transform);}
                 *      }
                 *      else {
                 *              //Debug.Log(cc.text + "!=" + _ss);
                 *      }
                 * }
                 */
                if (choiceObj == null)
                {
                    choiceObj      = GameObject.Instantiate(choicePrefab);
                    choiceObj.name = Random.Range(0, 99999).ToString();
                    choices.Add(choiceObj.transform);
                    choiceObj.transform.SetParent(choiceAnchor);
                }

                RectTransform rect = choiceObj.GetComponent <RectTransform>();
                rect.anchoredPosition = new Vector2(10 * i, rect.anchoredPosition.y);

                UIFadeIn fade = choiceObj.GetComponent <UIFadeIn>();
                if (fade)
                {
                    fade.delay = 0.7f + 0.5f * i;
                }

                Text _t = choiceObj.GetComponentInChildren <Text>();
                _t.text = HandleLine(choice.text);

                Button b = choiceObj.GetComponent <Button>();
                if (b == null)
                {
                    b = choiceObj.AddComponent <Button>();
                }
                else
                {
                    b.enabled = true;
                }
                b.onClick.AddListener(() => StartCoroutine(SelectChoice(ind)));

                ChoiceObject _choiceObj = choiceObj.GetComponent <ChoiceObject>();
                if (_choiceObj == null)
                {
                    _choiceObj = choiceObj.AddComponent <ChoiceObject>();
                }
                _choiceObj.choiceIndex = ind;
                _choiceObj.text        = choice.text;

                StartCoroutine(UIManager.instance.LoadChoice(choiceObj));
            }
        }
        lastChoices.Clear();
        FadeElement _fade = choiceAnchor.GetComponent <FadeElement>();

        if (_fade)
        {
            if (choices.Count > 0)
            {
                _fade.target = 1;
            }
            else
            {
                _fade.target = 0;
            }
        }
        //if (canContinueIndicator) {canContinueIndicator.SetAsLastSibling();}
        Canvas.ForceUpdateCanvases();
        yield return(null);
    }