public void NestOption_sampling_from_uniform_space_test()
        {
            var nestOption = new NestOption();

            nestOption.Add("choice", new ChoiceOption("a", "b", "c"));
            nestOption.Add("int", new UniformIntOption(0, 1));
            var anotherNestOption = new NestOption();

            anotherNestOption["choice"] = new ChoiceOption("d", "e");
            anotherNestOption["int"]    = new UniformIntOption(2, 3);
            nestOption["nestOption"]    = anotherNestOption;

            nestOption.FeatureSpaceDim.Should().Be(4);
            var parameter = nestOption.SampleFromFeatureSpace(new double[] { 0, 0, 0, 0 });

            parameter["nestOption"]["choice"].AsType <string>().Should().Be("d");
            parameter["nestOption"]["int"].AsType <int>().Should().Be(2);
            parameter["choice"].AsType <string>().Should().Be("a");
            parameter["int"].AsType <int>().Should().Be(0);

            parameter = nestOption.SampleFromFeatureSpace(new double[] { 1, 1, 1, 1 });
            parameter["nestOption"]["choice"].AsType <string>().Should().Be("e");
            parameter["nestOption"]["int"].AsType <int>().Should().Be(3);
            parameter["choice"].AsType <string>().Should().Be("c");
            parameter["int"].AsType <int>().Should().Be(1);
        }
Beispiel #2
0
    public void SetAtomA(Atom atom)
    {
        if (atom != null && atomChoices.Count > atom.GetAtomicNumber())
        {
            ChoiceOption choiceOption = atomChoices[atom.GetAtomicNumber() - 1];
            choiceOption.SetButtonEvent(() => {
                RemoveAtomA();
                AudioManager.Instance.PlaySound(choiceClickSound);
            });
            choiceOption.SetColors(ChoiceOption.defaultPressedColor, ChoiceOption.defaultHoverColor, ChoiceOption.defaultNormalColor);
            choiceOption.SetFocus(false);
        }

        atomA = atom;
        //atomChoices[atomA.GetAtomicNumber() - 1].SetInteractable(false);

        AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber());
        AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber());

        atomAText.text    = info.GetAtom().GetName();
        atomAImage.sprite = info.GetImage();

        atomAAmo.maxValue = data.GetCurrAmo();
        SetAtomAAmoText();

        atomABtn.interactable = true;
    }
Beispiel #3
0
    public static void CreateDoChoice(Action doAction, string question)
    {
        var choices = new ChoiceOption[] { new ChoiceOption("Gob gob", doAction), Instance.NoOption };


        Instance.StartCoroutine(Instance.OpenWhenReady(choices, question));
    }
Beispiel #4
0
    public void RemoveUpgrade()
    {
        if (choices.Count > (int)currUpgradeType)
        {
            ChoiceOption choiceOption = choices[(int)currUpgradeType];
            var          type         = currUpgradeType;
            choiceOption.SetButtonEvent(() => {
                SetUpgradeInfo(type);
                AudioManager.Instance.PlaySound(choiceClick);
            });
            choiceOption.SetColors(ChoiceOption.defaultNormalColor, ChoiceOption.defaultHoverColor, ChoiceOption.defaultPressedColor);
            choiceOption.SetFocus(false);
        }

        upgradeName.text      = "Upgrade";
        upgradeDesc.text      = "";
        upgradeCurrValue.text = "Curr Value: ";
        upgradeNextValue.text = "Next Value: ";

        upgradeAtomNeed.text = "";
        upgradeAtomName.text = "";
        upgradeAtomHave.text = "";

        upgradeBtn.interactable = false;
    }
Beispiel #5
0
        public void ArsenalServiceRefreshCache_Test()
        {
            try
            {
                Config.Cache.RefreshCache();

                RelationLeagueTeam.Clean();
                RelationLeagueTeam.Cache.RefreshCache();

                League.Cache.RefreshCache();
                Match.Cache.RefreshCache();
                Player.Cache.RefreshCache();
                Team.Cache.RefreshCache();
                Video.Cache.RefreshCache();

                //AcnCasino
                CasinoItem.Clean();
                ChoiceOption.Clean();
                Bet.Clean();
                BetDetail.Clean();

                // Clean Log
                Log.Clean();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
    void CheckForChangedOptions()
    {
        for (int i = 0; i < choiceHolder.createdOptions.Count; i++)
        {
            ChoiceOption inspectedOption = choiceHolder.createdOptions [i];
            if (inspectedOption.removeOption)
            {
                choiceHolder.Insp_RemoveOption(i);
                createdOptions.RemoveAt(i);
                prevChoiceCount--;

                Debug.Log("destroyed option, repainting scene");
                SceneView.RepaintAll();
            }
            else if (inspectedOption.buttonText != createdOptions [i].buttonText || inspectedOption.dialogText != createdOptions [i].dialogText)
            {
                createdOptions [i].buttonText = inspectedOption.buttonText;
                createdOptions [i].dialogText = inspectedOption.dialogText;
                choiceHolder.createdOptions [i].UpdateText();
            }
            else if (inspectedOption.longerDialog != createdOptions[i].longerDialog)
            {
                createdOptions [i].longerDialog = inspectedOption.longerDialog;
                choiceHolder.createdOptions [i].UpdateText();
            }
            else if (inspectedOption.responseAction != createdOptions [i].responseAction)
            {
                createdOptions [i].responseAction = inspectedOption.responseAction;
                inspectedOption.UpdateResponseAction();
            }
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        DrawPropertiesExcluding(serializedObject, "m_Script", "createdOptions", "optionPrefab");
        ShowList(serializedObject.FindProperty("createdOptions"));

        int choiceCount = choiceHolder.createdOptions.Count;

        if (prevChoiceCount != choiceCount)
        {
            if (choiceCount > prevChoiceCount)
            {
                for (int i = prevChoiceCount; i < choiceCount; i++)
                {
                    ChoiceOption newOption = null;
                    choiceHolder.Insp_CreateVisibleOption(i, out newOption);
                    createdOptions.Add(EditorOptionFromOption(newOption));
                }
            }
            else
            {
                Debug.LogWarning("Corrupted choice holder");
            }

            prevChoiceCount = choiceCount;
        }

        CheckForChangedOptions();

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #8
0
        public void Choice_option_with_one_value_sampling_from_uniform_space_test()
        {
            var option = new ChoiceOption("a");

            option.SampleFromFeatureSpace(new[] { 0.0 }).AsType <string>().Should().Be("a");
            option.SampleFromFeatureSpace(new[] { 0.99 }).AsType <string>().Should().Be("a");
        }
Beispiel #9
0
    public void RemoveAtomA()
    {
        if (atomA != null && atomChoices.Count > atomA.GetAtomicNumber())
        {
            ChoiceOption choiceOption = atomChoices[atomA.GetAtomicNumber() - 1];
            var          atom         = atomA;
            choiceOption.SetButtonEvent(() => {
                SetAtom(atom);
                AudioManager.Instance.PlaySound(choiceClickSound);
            });
            choiceOption.SetColors(ChoiceOption.defaultNormalColor, ChoiceOption.defaultHoverColor, ChoiceOption.defaultPressedColor);
            choiceOption.SetFocus(false);
        }

        //if (atomA != null) {
        //    atomChoices[atomA.GetAtomicNumber() - 1].SetInteractable(true);
        //}
        atomA = null;

        AtomInfo info = Game.Instance.gameData.GetUknownInfo();

        atomAText.text    = info.GetAtom().GetName();
        atomAImage.sprite = info.GetImage();

        splitBtn.interactable  = false;
        infoText.text          = "";
        atomResultImage.sprite = info.GetImage();
        atomResultText.text    = info.GetAtom().GetName();
        atomAAmoText.text      = "";
        atomAAmo.value         = 0;

        atomABtn.interactable = false;
    }
Beispiel #10
0
        public void Choice_option_mapping_to_uniform_space_test()
        {
            var option = new ChoiceOption("a", "b", "c");

            option.MappingToFeatureSpace(Parameter.FromString("a"))[0].Should().BeApproximately(0, 1e-5);
            option.MappingToFeatureSpace(Parameter.FromString("b"))[0].Should().BeApproximately(0.333333, 1e-5);
            option.MappingToFeatureSpace(Parameter.FromString("c"))[0].Should().BeApproximately(0.666666, 1e-5);
        }
Beispiel #11
0
 public EnumOption(string name, string value, string originalName, ChoiceOption option, ChoiceFieldSetting choiceFielSetting, Class @class)
 {
     _class             = @class;
     _choiceFielSetting = choiceFielSetting;
     Name         = name;
     OriginalName = originalName;
     Value        = value;
 }
        /// <summary>
        /// Create a <see cref="ChoiceAttribute"/> with <paramref name="candidates"/>.
        /// </summary>
        public ChoiceAttribute(params object[] candidates)
        {
            var candidatesType = candidates.Select(o => o.GetType()).Distinct();

            Contracts.Assert(candidatesType.Count() == 1, "multiple candidates type detected");

            Option = new ChoiceOption(candidates.Select(c => Convert.ToString(c, CultureInfo.InvariantCulture)).ToArray());
        }
Beispiel #13
0
        public async Task AddChoiceOptionsAsync(int fieldDataId, int optionPosition, bool value, string viewValue)
        {
            var fieldData = await _fieldDataRepository.GetByIdAsync(fieldDataId);

            var choiceOption = new ChoiceOption(optionPosition, value, viewValue);

            fieldData.AddChoiceOption(choiceOption);
            await _choiceOptionRepository.AddAsync(choiceOption);
        }
Beispiel #14
0
        public void Choice_option_dimension_should_be_0_if_contains_only_one_value()
        {
            var option = new ChoiceOption("b");

            option.FeatureSpaceDim.Should().Be(0);
            option.Default.Should().BeEquivalentTo();
            option.SampleFromFeatureSpace(new double[0]).AsType <string>().Should().Be("b");
            option.MappingToFeatureSpace(Parameter.FromString("b")).Should().BeEmpty();
        }
        /// <summary>
        /// Create a <see cref="ChoiceAttribute"/> with <paramref name="candidates"/> and <paramref name="defaultValue"/>.
        /// </summary>
        public ChoiceAttribute(object[] candidates, object defaultValue)
        {
            var candidatesType = candidates.Select(o => o.GetType()).Distinct();

            Contracts.Assert(candidatesType.Count() == 1, "multiple candidates type detected");
            Contracts.Assert(candidatesType.First() == defaultValue.GetType(), "candidates type doesn't match with defaultValue type");

            Option = new ChoiceOption(candidates.Select(c => Convert.ToString(c, CultureInfo.InvariantCulture)).ToArray(), Convert.ToString(defaultValue, CultureInfo.InvariantCulture));
        }
    //all that the editor knows about the options is the text, the responseAction and the amount of options
    //this function is useful when a new option is created and for initialization OnEnable
    ChoiceOption EditorOptionFromOption(ChoiceOption option)
    {
        ChoiceOption newEditorOption = new ChoiceOption();

        newEditorOption.buttonText     = option.buttonText;
        newEditorOption.dialogText     = option.dialogText;
        newEditorOption.longerDialog   = option.longerDialog;
        newEditorOption.responseAction = option.responseAction;
        return(newEditorOption);
    }
Beispiel #17
0
    public void Initialization(string key, string text, bool isEnabled, string imageName, string helpText)
    {
        var sut = new ChoiceOption(key, text, isEnabled, imageName, helpText);

        sut.Key.Should().Be(key);
        sut.Text.Should().Be(text);
        sut.IsEnabled.Should().Be(isEnabled);
        sut.ImageName.Should().Be(imageName);
        sut.HelpText.Should().Be(helpText);
    }
Beispiel #18
0
 public void Update(float delta)
 {
     if (AKS.WasJustPressed(Mouse.Button.Left) && Utils.PointIsInRect(Game.MousePosition, _retryLevelBackground))
     {
         Choice = ChoiceOption.RetryLevel;
     }
     else if (AKS.WasJustPressed(Mouse.Button.Left) && Utils.PointIsInRect(Game.MousePosition, _returnToTitleBackground))
     {
         Choice = ChoiceOption.ReturnToTitle;
     }
 }
Beispiel #19
0
    public void Insp_CreateVisibleOption(int optionIndex, out ChoiceOption option)
    {
        option = new ChoiceOption();
        Vector3 optionPos = nextOptionPos;

        option.CreateOption(optionPrefab, transform, optionPos);
        option.InitButton(this, optionIndex);
        createdOptions [optionIndex] = option;

        nextOptionPos += optionOffset;
    }
Beispiel #20
0
    private void AddElement(Atom a, ChoiceOption c)
    {
        if (discoveredAtoms.Contains(a))
        {
            return;
        }

        c.gameObject.SetActive(true);
        discoveredAtoms.Add(a);
        SortElements();
    }
Beispiel #21
0
        public void Choice_option_sampling_from_uniform_space_test()
        {
            var option = new ChoiceOption("a", "b", "c");

            option.SampleFromFeatureSpace(new[] { 0.0 }).AsType <string>().Should().Be("a");
            option.SampleFromFeatureSpace(new[] { 0.33 }).AsType <string>().Should().Be("a");
            option.SampleFromFeatureSpace(new[] { 0.34 }).AsType <string>().Should().Be("b");
            option.SampleFromFeatureSpace(new[] { 0.66 }).AsType <string>().Should().Be("b");
            option.SampleFromFeatureSpace(new[] { 0.67 }).AsType <string>().Should().Be("c");
            option.SampleFromFeatureSpace(new[] { 0.97 }).AsType <string>().Should().Be("c");
            option.SampleFromFeatureSpace(new[] { 0.999999999 }).AsType <string>().Should().Be("c");
        }
    void OnEnable()
    {
        choiceHolder = (ChoiceHolder)target;
        choiceHolder.Insp_Enabled();

        prevChoiceCount = choiceHolder.createdOptions.Count;
        createdOptions.Clear();
        for (int i = 0; i < prevChoiceCount; i++)
        {
            ChoiceOption editorOption = EditorOptionFromOption(choiceHolder.createdOptions [i]);
            createdOptions.Add(editorOption);
        }
    }
Beispiel #23
0
        public void Choice_option_mapping_to_uniform_space_test()
        {
            var option = new ChoiceOption("a", "b", "c");

            option.MappingToFeatureSpace(Parameter.FromString("a"))[0].Should().BeApproximately(0, 1e-5);
            option.MappingToFeatureSpace(Parameter.FromString("b"))[0].Should().BeApproximately(0.333333, 1e-5);
            option.MappingToFeatureSpace(Parameter.FromString("c"))[0].Should().BeApproximately(0.666666, 1e-5);

            option = new ChoiceOption("a", "b", "c", "d");
            var parameter = option.SampleFromFeatureSpace(new[] { 0.5 });

            parameter.AsType <string>().Should().Be("c");
            option.MappingToFeatureSpace(parameter).Should().Equal(0.5);
        }
Beispiel #24
0
    private void SelectOption(ChoiceOption o)
    {
        if (!ActionSelected)
        {
            //Debug.Log("Selected optino: " + o.Description);

            if (o.Action != null)
            {
                o.Action.Invoke();
            }

            ActionSelected = true;
            CloseWindow();
        }
    }
Beispiel #25
0
    private void AddCraftable(ChoiceOption c)
    {
        var pos = c.transform.localPosition;

        pos.y = yPos;
        c.transform.localPosition = pos;
        yPos -= 50;


        var sizeDelta = craftableListRect.sizeDelta;

        sizeDelta.y = startPos - yPos + 10;
        craftableListRect.sizeDelta = sizeDelta;

        c.gameObject.SetActive(true);
    }
Beispiel #26
0
        public void Execute(object state)
        {
            var logInfo = new LogInfo
            {
                MethodInstance = MethodBase.GetCurrentMethod(),
                ThreadInstance = Thread.CurrentThread
            };

            //string _scheduleType = this.GetType().DeclaringType.FullName;

            try
            {
                log.Info("Scheduler Start: (RefreshCache)", logInfo);

                Config.UpdateAssemblyInfo(Assembly.GetExecutingAssembly(), ConfigSystem.Arsenal);

                ConfigGlobal_Arsenal.Refresh();

                RelationLeagueTeam.Clean();
                RelationLeagueTeam.Cache.RefreshCache();

                RelationGroupTeam.Clean();
                RelationLeagueTeam.Cache.RefreshCache();

                League.Cache.RefreshCache();
                Match.Cache.RefreshCache();
                Player.Cache.RefreshCache();
                Team.Cache.RefreshCache();
                Video.Cache.RefreshCache();

                //AcnCasino
                CasinoItem.Clean();
                ChoiceOption.Clean();
                Bet.Clean();
                BetDetail.Clean();

                // Clean Log
                Log.Clean();

                log.Info("Scheduler End: (RefreshCache)", logInfo);
            }
            catch (Exception ex)
            {
                log.Warn(ex, logInfo);
            }
        }
        private static void ModifyListBox(ListBoxField listField, IEnumerable <string> options, int selectedIndex)
        {
            listField.Options.Clear();
            int index = 0;

            foreach (string text in options)
            {
                ChoiceOption option = new ChoiceOption(text);
                listField.Options.Add(option);

                if (index == selectedIndex)
                {
                    listField.Value = new ChoiceOption[] { option };
                }

                index++;
            }
        }
Beispiel #28
0
    public void SetChoiceDisplay(ChoiceOption choice, PlayerData.UpgradeType type)
    {
        string text = "";

        switch (type)
        {
        case PlayerData.UpgradeType.Collect_Speed:
            text = "Collect Speed Lv. ";
            break;

        case PlayerData.UpgradeType.Collect_Radius:
            text = "Collect Radius Lv. ";
            break;

        case PlayerData.UpgradeType.Collect_Efficiency:
            text = "Collect Efficiency Lv. ";
            break;

        case PlayerData.UpgradeType.Collect_Weight:
            text = "Collect Weight Lv. ";
            break;

        case PlayerData.UpgradeType.Particle_Speed:
            text = "Particle Speed Lv. ";
            break;

        case PlayerData.UpgradeType.Particle_Stability:
            text = "Particle Stability Lv. ";
            break;

        case PlayerData.UpgradeType.Time_Dilation:
            text = "Time Dilation Lv. ";
            break;
        }

        if (Game.Instance.playerData.IsMaxLevel(type))
        {
            choice.SetText(text + "MAX");
        }
        else
        {
            choice.SetText(text + Game.Instance.playerData.GetUpgradeLevel(type));
        }
    }
Beispiel #29
0
        public Choice(ChoiceOption option)
        {
            switch (option)
            {
            case ChoiceOption.Yes:
                Text        = "Yes";
                Description = "Click or press Y to agree.";
                Key         = Key.Y;
                Color       = Green;
                break;

            case ChoiceOption.No:
                Text        = "No";
                Description = "Click or press N to disagree.";
                Key         = Key.N;
                Color       = Red;
                break;

            case ChoiceOption.Cancel:
                Text        = "Cancel";
                Description = "Click or press Escape to cancel.";
                Key         = Key.Escape;
                Color       = Red;
                break;

            case ChoiceOption.Ok:
                Text        = "OK";
                Description = "Click or press Enter to confirm.";
                Key         = Key.Enter;
                Color       = Green;
                break;

            case ChoiceOption.Continue:
                Text        = "Continue";
                Description = "Click or press Space to continue.";
                Key         = Key.Space;
                Color       = Blue;
                break;

            default:
                throw new ArgumentException("Invalid choice option: " + option);
            }
        }
Beispiel #30
0
    private void SortElements()
    {
        discoveredAtoms.Sort();

        startPos = -5;
        yPos     = startPos;
        for (int i = 0; i < discoveredAtoms.Count; i++)
        {
            ChoiceOption c = atomChoices[discoveredAtoms[i].GetAtomicNumber() - 1];

            var pos = c.transform.localPosition;
            pos.y = yPos;
            c.transform.localPosition = pos;
            yPos -= 50;
        }

        var sizeDelta = atomList.sizeDelta;

        sizeDelta.y        = startPos - yPos + 10;
        atomList.sizeDelta = sizeDelta;
    }