コード例 #1
0
    private void OnActivate()
    {
        int ruleNumber = GetRuleNumber();

        if (ruleNumber < 5 || !BombInfo.IsTwoFactorPresent())
        {
            Debug.LogFormat("[Colors Maximization #{0}] Using rule #{1}", moduleId, ruleNumber);
            Debug.LogFormat("[Colors Maximization #{0}] \tColors sorted by score: {1}", moduleId, rules[ruleNumber - 1].Select(c => colorNames[c]).Join(","));
            GetExpectedScore(ruleNumber, true);
        }
        else
        {
            answerIsDynamic = true;
            Debug.LogFormat("[Colors Maximization #{0}] Rule is dynamic", moduleId);
            Debug.LogFormat("[Colors Maximization #{0}] When rule #5 is used:", moduleId);
            Debug.LogFormat("[Colors Maximization #{0}] \tColors sorted by score: {1}", moduleId, rules[5].Select(c => colorNames[c]).Join(","));
            GetExpectedScore(5, true);
            Debug.LogFormat("[Colors Maximization #{0}] When rule #6 is used:", moduleId);
            Debug.LogFormat("[Colors Maximization #{0}] \tColors sorted by score: {1}", moduleId, rules[6].Select(c => colorNames[c]).Join(","));
            GetExpectedScore(6, true);
        }
        foreach (ButtonComponent button in buttons)
        {
            ButtonComponent closure = button;
            button.Selectable.OnInteract += () => OnButtonPressed(closure);
        }
    }
コード例 #2
0
        private CuratedExperienceAnswers ExtractLogic(CuratedExperienceComponent component, CuratedExperienceAnswers answers)
        {
            // when dealing with finding next destination of the current component we need to remove all logic
            // except the specific GOTO statement that comes in the current component. That is why I'm setting all logic to string.Empty.
            foreach (var answer in answers.ButtonComponents)
            {
                answer.CodeBefore = string.Empty;
                answer.CodeAfter  = string.Empty;
            }
            foreach (var answer in answers.FieldComponents)
            {
                answer.CodeBefore = string.Empty;
                answer.CodeAfter  = string.Empty;
            }
            if (!string.IsNullOrWhiteSpace(component.Code.CodeBefore) || !string.IsNullOrWhiteSpace(component.Code.CodeAfter))
            {
                var button = new ButtonComponent();
                button.ButtonId   = Guid.NewGuid();
                button.Name       = string.Empty;
                button.Value      = string.Empty;
                button.CodeBefore = component.Code.CodeBefore;
                button.CodeAfter  = component.Code.CodeAfter;
                answers.ButtonComponents.Add(button);
            }

            return(answers);
        }
コード例 #3
0
ファイル: ButtonBuilder.cs プロジェクト: ProIcons/Mmcc.Bot
 public ButtonBuilder(ButtonComponentStyle style)
 {
     _snowflake          = Snowflake.CreateTimestampSnowflake(DateTimeOffset.UtcNow);
     _buttonComponent    = new(style);
     _handler            = null;
     _requiredPermission = new();
 }
コード例 #4
0
ファイル: ButtonBuilder.cs プロジェクト: ProIcons/Mmcc.Bot
 public ButtonBuilder WithEmoji(Snowflake id)
 {
     _buttonComponent = _buttonComponent with {
         Emoji = new PartialEmoji(id)
     };
     return(this);
 }
コード例 #5
0
    void BuildElement(bool exit, int toNode, string text, bool isActiveButton, int reputation, int power, int money, bool end)
    {
        ButtonComponent clone = Instantiate(button) as ButtonComponent;

        if (hero.money + money < 0)
        {
            isActiveButton = false; text += "(Недостаточно денег!)";
        }
        clone.gameObject.SetActive(true);
        clone.rect.SetParent(scrollRect.content);
        clone.rect.localScale = Vector3.one;
        clone.text.text       = text;
        if (money != 0)
        {
            clone.text.text += " Цена: " + (-money);
        }
        clone.rect.sizeDelta      = new Vector2(clone.rect.sizeDelta.x, clone.text.preferredHeight + offset);
        clone.button.interactable = isActiveButton;
        height = clone.rect.sizeDelta.y;
        clone.rect.anchoredPosition = new Vector2(0, -height / 2 - curY);

        if (toNode > 0)
        {
            SetNextDialogue(clone.button, toNode, reputation, power, money);
        }
        if (exit)
        {
            SetExitDialogue(clone.button, reputation, power, money, end);
        }
        buttons.Add(clone.rect);
    }
コード例 #6
0
            public static ButtonComponent Read(BinaryReader br)
            {
                ButtonComponent ret = new ButtonComponent();

                ret.Data = br.ReadStructures <UInt32>(2).ToArray();
                return(ret);
            }
コード例 #7
0
ファイル: ButtonBuilder.cs プロジェクト: ProIcons/Mmcc.Bot
 public ButtonBuilder WithEmoji(string unicode)
 {
     _buttonComponent = _buttonComponent with {
         Emoji = new PartialEmoji(Name: unicode)
     };
     return(this);
 }
コード例 #8
0
ファイル: Utilities.cs プロジェクト: Antis28/LinguaLeo
    public int Compare(object x, object y)
    {
        ButtonComponent lVal  = x as ButtonComponent;
        ButtonComponent rValt = y as ButtonComponent;

        return(Compare(lVal.gameObject, rValt.gameObject));
    }
    public void UpdateBodyContentSize()
    {
        tab.geometry.tabContent.rect.width  = 0;
        tab.geometry.tabContent.rect.height = 0;

        /*
         *
         * for (int i= 0;i< tab.structure.childrenTabs.Count;i++) { tab.geometry.tabContent.rect = AddToRect(tab.geometry.tabContent.rect, tab.structure.childrenTabs[i].tab.geometry.tabContainer.rect); }
         * for (int i= 0;i< tab.structure.childrenTextAreas.Count;i++) { tab.geometry.tabContent.rect = AddToRect(tab.geometry.tabContent.rect, tab.structure.childrenTextAreas[i].textarea.geometry.textareaBody.rect); }
         * for (int i= 0;i< tab.structure.childrenButtons.Count;i++) { tab.geometry.tabContent.rect = AddToRect(tab.geometry.tabContent.rect, tab.structure.childrenButtons[i].button.geometry.buttonBody.rect); }
         */
        for (int i = 0; i < tab.structure.children.Components.Count; i++)
        {
            TabComponent      childTab      = tab.structure.children.Components[i].GetComponent <TabComponent>();
            ButtonComponent   childButton   = tab.structure.children.Components[i].GetComponent <ButtonComponent>();
            TextareaComponent childTextarea = tab.structure.children.Components[i].GetComponent <TextareaComponent>();

            if (childTab != null)
            {
                tab.geometry.tabContent.rect = AddToRect(tab.geometry.tabContent.rect, childTab.tab.geometry.tabContainer.rect);
            }
            else
            if (childButton != null)
            {
                tab.geometry.tabContent.rect = AddToRect(tab.geometry.tabContent.rect, childButton.button.geometry.buttonBody.rect);
            }
            else
            if (childTextarea != null)
            {
                tab.geometry.tabContent.rect = AddToRect(tab.geometry.tabContent.rect, childTextarea.textarea.geometry.textareaBody.rect);
            }
        }
    }
コード例 #10
0
    private void FillSamleText(ButtonComponent button)
    {
        WordToTranslate wordToTranslate = FindObjectOfType <WordToTranslate>();

        if (!button || !wordToTranslate)
        {
            Debug.LogWarning("Не найден WordToTranslate");
            return;
        }

        QuestionLeo quest = wordToTranslate.GetCurrentQuest();
        WordLeo     word  = null;

        foreach (var item in quest.answers)
        {
            if (button.text.text == item.translations ||
                button.text.text == item.wordValue)
            {
                word = item;
                break;
            }
        }
        if (word == null)
        {
            return;
        }
        if (button.text.text == word.translations)
        {
            SampleText.text = word.translations + " → " + word.wordValue;
        }
        else
        {
            SampleText.text = word.wordValue + " → " + word.translations;
        }
    }
コード例 #11
0
    public override void OnInit()
    {
        this.content = this.GetLayoutComponent <UIWindowExampleComponent>();
        this.button  = this.GetLayoutComponent <ButtonComponent>();

        this.button.SetCallback(this.Hide);
    }
コード例 #12
0
    public void OnNotify(object parametr, GAME_EVENTS notificationName)
    {
        ButtonComponent button = null;

        if (parametr != null)
        {
            button = ((Component)parametr).GetComponent <ButtonComponent>();
        }
        if (ResultText == null)
        {
            return;
        }
        switch (notificationName)
        {
        case GAME_EVENTS.CorrectAnswer:
            ResultText.text  = "Верный ответ.";
            ResultText.color = correctColor;
            break;

        case GAME_EVENTS.NonCorrectAnswer:
            ResultText.text  = "Неверный ответ.";
            ResultText.color = wrongColor;
            FillSamleText(button);
            break;

        case GAME_EVENTS.BuildTask:
            ResultText.text = string.Empty;
            SampleText.text = string.Empty;
            break;
        }
    }
コード例 #13
0
 private KMSelectable[] ProcessTwitchCommand(string command)
 {
     command = command.Trim().ToLower();
     if (command == "colorblind")
     {
         colorblindModeEnabled = !colorblindModeEnabled;
         return(new KMSelectable[0]);
     }
     if (Regex.IsMatch(command, @"activate( *all)?"))
     {
         Dictionary <Color, KMSelectable> keys = new Dictionary <Color, KMSelectable>();
         for (int y = 0; y < HEIGHT; y++)
         {
             for (int x = 0; x < WIDTH; x++)
             {
                 ButtonComponent button = buttonsGrid[x][y];
                 if (!button.active && !keys.ContainsKey(button.primaryColor))
                 {
                     keys[button.primaryColor] = button.GetComponent <KMSelectable>();
                 }
             }
         }
         return(keys.Values.ToArray());
     }
     KMSelectable[] parsedCoords = ParseButtonsSet(command);
     if (parsedCoords != null)
     {
         return(parsedCoords);
     }
     return(null);
 }
コード例 #14
0
    // Use this for initialization
    void Start()
    {
        a = gameObject.transform.GetComponentInChildren <TabComponent>();
        b = gameObject.transform.GetComponentInChildren <ButtonComponent>();

        if (a != null)
        {
            // print(a.tab.data.name);
            //TypeGeneric.Component ge = GetGen(a.tab);
            GenericType.Component ge = TabType.Generic(a.tab);

            print(ge.data.name + "_____");
        }
        else
        {
            print("No Tabs Found");
        }



        if (b != null)
        {
            print(b.button.data.name);
        }



        //parent
    }
コード例 #15
0
ファイル: ButtonBuilder.cs プロジェクト: ProIcons/Mmcc.Bot
 public ButtonBuilder AsDisabled()
 {
     _buttonComponent = _buttonComponent with {
         IsDisabled = true
     };
     return(this);
 }
コード例 #16
0
ファイル: ButtonBuilder.cs プロジェクト: ProIcons/Mmcc.Bot
 public ButtonBuilder WithLabel(string label)
 {
     _buttonComponent = _buttonComponent with {
         Label = label
     };
     return(this);
 }
コード例 #17
0
ファイル: ButtonsHandler.cs プロジェクト: Antis28/LinguaLeo
    private void EnterButtonToNext(ButtonComponent extraB)
    {
        // Отдельная кнопка "следующее"
        extraB.text.text = NEXT_WORD;
        extraB.button.GetComponentInChildren <Text>().color = Color.white;

        SetColors(extraB.button, new Color(68f / 255, 145 / 255f, 207f / 255));
    }
コード例 #18
0
        public virtual PartialViewResult Button(ButtonComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            return(PartialView(component));
        }
コード例 #19
0
ファイル: ButtonsHandler.cs プロジェクト: Antis28/LinguaLeo
    private void EnterButtonToDontKnow(ButtonComponent extraB)
    {
        // Отдельная кнопка "не знаю"
        extraB.text.text = DONT_KNOW;
        extraB.button.GetComponentInChildren <Text>().color = Color.black;
        SetColors(extraB.button, Color.white);

        JoinShowResult(buttons[buttonID].button, false);
    }
コード例 #20
0
 public Button(GameObject gameObejcet, GameObject parent, Action action, string name, Vector3 position)
 {
     gameObject = gameObejcet;
     gameObject.AddComponent <ButtonComponent>();
     buttonComponent                    = gameObject.GetComponent <ButtonComponent>();
     buttonComponent.action             = action;
     gameObject.transform.parent        = parent.transform;
     gameObject.name                    = name;
     gameObject.transform.localPosition = position;
 }
コード例 #21
0
    public ButtonComponentSolver(BombCommander bombCommander, ButtonComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        ModuleInformation buttonInfo         = ComponentSolverFactory.GetModuleInfo("ButtonComponentSolver", "!{0} tap [tap the button] | !{0} hold [hold the button] | !{0} release 7 [release when the digit shows 7]");
        ModuleInformation buttonInfoModified = ComponentSolverFactory.GetModuleInfo("ButtonComponentModifiedSolver", "Click the button with !{0} tap. Click the button at time with !{0} tap 8:55 8:44 8:33. Hold the button with !{0} hold. Release the button with !{0} release 9:58 9:49 9:30.");

        bombComponent.GetComponent <Selectable>().OnCancel += bombComponent.OnButtonCancel;
        _button = bombComponent.button;
        modInfo = VanillaRuleModifier.IsSeedVanilla() ? buttonInfo : buttonInfoModified;
    }
コード例 #22
0
        public bool ButtonReleased(BombComponent component)
        {
            int             num             = base.ExecuteRuleList(component, this.RuleList);
            ButtonComponent buttonComponent = (ButtonComponent)component;
            int             num2            = base.ExecuteRuleList(component, this.HoldRuleList);

            if (!buttonComponent.IsHolding)
            {
                num2 = 0;
            }
            return(num == 0 && num2 == 0);
        }
コード例 #23
0
ファイル: ButtonBuilder.cs プロジェクト: ProIcons/Mmcc.Bot
        public ButtonBuilder WithUrl(string url)
        {
            if (_buttonComponent.Style is not ButtonComponentStyle.Link)
            {
                throw new InvalidOperationException("ButtonComponentStyle must be set to Link to use WithUrl.");
            }

            _buttonComponent = _buttonComponent with {
                URL = url
            };
            return(this);
        }
コード例 #24
0
    public override void OnInit()
    {
        this.contentComponent = this.GetLayoutComponent <UIWindowExampleComponent>();

        this.buttonAlert = this.GetLayoutComponent <ButtonComponent>(LayoutTag.Tag4);
        this.buttonAlert.SetCallback(this.OnAlert);

        this.button = this.GetLayoutComponent <ButtonWithTipComponent>();
        this.button.SetCallback(this.OnClick);

        this.button.SetTextToTip("<b>Click here to open new instance.</b>\nYou can simply edit this text or pass it from the code. See UIWindowExampleTip and UIWindowExampleScreen.");
    }
コード例 #25
0
    public async Task <IResult> Test()
    {
        var id        = new Snowflake((ulong)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
        var component = new ButtonComponent(ButtonComponentStyle.Primary, "Test",
                                            CustomID: id.ToString());
        var testButton =
            HandleableButton.Create <TestHandler.Command, TestHandler.Context>(id, component,
                                                                               new TestHandler.Context(_context.ChannelID));

        _handlerRepository.Register(testButton);

        return(await _responder.RespondWithComponents(ActionRowUtils.FromButtons(testButton), "Test buttons"));
    }
コード例 #26
0
    private void OnClick(ButtonComponent button)
    {
        var index = this.GetIndexOf(button);

        if (index < 0)
        {
            return;
        }

        var window = this.GetWindow() as UIWindowExampleTransitions;

        window.ShowWindow(index);
    }
コード例 #27
0
    void InitiateObjectPool()
    {
        for (int i = 0; i < 10; i++)
        {
            ButtonComponent clone = Instantiate(button) as ButtonComponent;
            clone.gameObject.SetActive(false);
            clone.rect.SetParent(scrollRect.content);
            clone.rect.localScale = Vector3.one;

            buttonsObjectPool.Add(clone);
            buttons.Add(clone.rect);
        }
    }
コード例 #28
0
 void Focus(ButtonComponent buttonComponent)
 {
     buttonComponent.Focused = true;
     if (buttonComponent.TextComponent != null)
     {
         buttonComponent.TextComponent.Color = buttonComponent.FocusedTextColor;
     }
     if (buttonComponent.SpriteComponent != null)
     {
         buttonComponent.SpriteComponent.CurrentAnimationObject = buttonComponent.FocusedAnimation;
     }
     focusedButton = buttonComponent;
 }
コード例 #29
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MenuScene);

            this.gamePlayManager   = WaveServices.GetService <GamePlayManager>();
            this.navigationManager = WaveServices.GetService <NavigationManager>();

            this.resumeComponent  = this.EntityManager.Find(GameConstants.ENTITYMENURESUME).FindComponent <ButtonComponent>();
            this.restartComponent = this.EntityManager.Find(GameConstants.ENTITYMENURESTART).FindComponent <ButtonComponent>();
            this.exitComponent    = this.EntityManager.Find(GameConstants.ENTITYMENUEXIT).FindComponent <ButtonComponent>();

            this.resumeComponent.StateChanged  += this.ResumeButtonStateChanged;
            this.restartComponent.StateChanged += this.RestartButtonStateChanged;
            this.exitComponent.StateChanged    += this.ExitButtonStateChanged;
        }
コード例 #30
0
        private void HandleButtonClick(ButtonComponent btn)
        {
            switch (btn.buttonName)
            {
            case "Play":
                Play();
                break;

            case "CancelSession":
                CancelSession();
                break;

            case "Autorization":
                OpenAuthWindow();
                break;

            case "AutorizationButton":
                AutorizationButton();
                break;

            case "CloseAutorization":
                menu.Get1[0].AutorizationWindow.enabled = false;
                break;

            case "CopyButton":
                CopyText();
                break;

            case "Options":
                OpenOptions();
                break;

            case "CancelSettings":
                CancelSettings();
                break;

            case "NickOkButton":
                TryAcceptNickname();
                break;

            case "Exit":
                world.NewEntityWith(out ExitGameEvent exit);
                break;

            default:
                break;
            }
        }