示例#1
0
    private void SelectNextOption(SelectableOption optionToSelect)
    {
        if (optionToSelect == null)
        {
            return;
        }

        if (currentlySelectedOption != null)
        {
            currentlySelectedOption.enabled = false;
        }

        currentlySelectedOption         = optionToSelect;
        currentlySelectedOption.enabled = true;
    }
示例#2
0
        private void MixEntryType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (MixEntryType.SelectedItem == null)
            {
                return;
            }

            SelectableOption <MixType> selectedType = DebugHelper.CastAndAssert <SelectableOption <MixType> >(MixEntryType.SelectedItem);

            switch (selectedType.Type & MixType.TYPE_MASK)
            {
            case MixType.NUMBER_TYPE:
                VisualStateManager.GoToState(this, "NumberSelected", false);

                UpdateNumericState(selectedType.Type);
                return;

            case MixType.STRING_TYPE:
                VisualStateManager.GoToState(this, "StringSelected", false);
                return;

            case MixType.NESTED_TYPE:
                VisualStateManager.GoToState(this, "NestedSelected", false);
                return;

            case MixType.RANGE_TYPE:
                VisualStateManager.GoToState(this, "RangeSelected", false);
                return;

            case MixType.MEMBER_TYPE:
                VisualStateManager.GoToState(this, "MemberSelected", false);

                UpdateMemberState(selectedType.Type);
                return;

            default:
                DebugHelper.Assert(new CallerInfo(), selectedType.Type == MixType.None, "Unexpected mix type: {0}", selectedType.Type);
                VisualStateManager.GoToState(this, "UnknownSelected", false);
                return;
            }
        }
示例#3
0
    public SelectableOption GetOptionWest()
    {
        if (westOption == null || wasInspected)
        {
            return(null);
        }

        if (optionActive)
        {
            return(westOption);
        }
        SelectableOption optionToReturn = null;

        if (westOption != null)
        {
            wasInspected   = true;
            optionToReturn = westOption.GetOptionWest();
            wasInspected   = false;
        }
        return(optionToReturn);
    }
示例#4
0
    public SelectableOption GetOptionSouth()
    {
        if (southOption == null || wasInspected)
        {
            return(southOption);
        }

        if (optionActive)
        {
            return(southOption);
        }
        SelectableOption optionToReturn = null;

        if (southOption != null)
        {
            wasInspected   = true;
            optionToReturn = southOption.GetOptionSouth();
            wasInspected   = false;
        }
        return(optionToReturn);
    }
示例#5
0
        public EditMix(MixViewModel mixToEdit)
        {
            this.InitializeComponent();

            this.DataContext = mixToEdit;

            SortTypeComboBox.ItemsSource = AllSortTypes;
            SelectableOption <MixSortOrder> selectedTypeEntry = AllSortTypes.Where((m) => { return(m.Type == (Mix.SortType & MixSortOrder.PROPERTY_MASK) || m.Type == Mix.SortType); }).FirstOrDefault();

            SortTypeComboBox.SelectedItem = selectedTypeEntry;

            SortOrderComboBox.ItemsSource = AllSortOrders;
            SelectableOption <MixSortOrder> selectedOrderEntry = AllSortOrders.Where((m) => { return(m.Type == (Mix.SortType & MixSortOrder.ORDER_MASK) || m.Type == Mix.SortType); }).FirstOrDefault();

            SortOrderComboBox.SelectedItem = selectedOrderEntry;

            RootMixEntry.LoadEvaluator(mixToEdit.RootEvaluator);

            RootMixEntry.TextBotGotFocus  += HandleMixLimitTextBoxGotFocus;
            RootMixEntry.TextBotLostFocus += HandleMixLimitTextBoxLostFocus;
        }
示例#6
0
        private void HandleContentDialogPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if ((deleteMix.IsChecked.HasValue && deleteMix.IsChecked.Value) &&
                (deleteMixConfirm.IsChecked.HasValue && deleteMixConfirm.IsChecked.Value))
            {
                LibraryViewModel.Current.DeleteMix(Mix);
            }
            else
            {
                Mix.Name = editMixName.Text;

                if (mixLimitCheckBox.IsChecked.HasValue)
                {
                    Mix.HasLimit = mixLimitCheckBox.IsChecked.Value;
                }

                uint newMixLimit;

                if (uint.TryParse(mixLimitTextBox.Text, out newMixLimit))
                {
                    Mix.Limit = newMixLimit;
                }

                if (mixHiddenCheckBox.IsChecked.HasValue)
                {
                    Mix.IsHidden = mixHiddenCheckBox.IsChecked.Value;
                }

                SelectableOption <MixSortOrder> selectedType  = DebugHelper.CastAndAssert <SelectableOption <MixSortOrder> >(SortTypeComboBox.SelectedItem);
                SelectableOption <MixSortOrder> selectedOrder = DebugHelper.CastAndAssert <SelectableOption <MixSortOrder> >(SortOrderComboBox.SelectedItem);

                Mix.SortType = selectedType.Type | selectedOrder.Type;

                IMixEvaluator mixEval = RootMixEntry.ConvertToEvaluator();
                Mix.SetEvaluator(mixEval);

                Mix.Reset();
            }
        }
示例#7
0
 internal void DisplayIcon(SelectableOption option)
 {
     spriteRenderer.sprite = option.sprite;
     textName.text         = option.name;
     associatedOption      = option;
 }
示例#8
0
 // Start is called before the first frame update
 public override void Activate(SelectableOption option)
 {
 }
 public override void Activate(SelectableOption option)
 {
     HumanHandler.instance.NewPlayer();
 }
示例#10
0
 // Start is called before the first frame update
 public override void Activate(SelectableOption option)
 {
     option.onSelected.boundBuilding.Build();
 }
 public abstract void Activate(SelectableOption option);
示例#12
0
 public override void Activate(SelectableOption option)
 {
     InventoryHandler.instance.Add(ItemType.Human, 2);
     HumanHandler.instance.SpawnHuman();
 }
示例#13
0
        public IMixEvaluator ConvertToEvaluator()
        {
            if (MixEntryType.SelectedItem == null)
            {
                return(new NoneMixEvaluator());
            }

            SelectableOption <MixType> selectedType = DebugHelper.CastAndAssert <SelectableOption <MixType> >(MixEntryType.SelectedItem);

            switch (selectedType.Type & MixType.TYPE_MASK)
            {
            case MixType.NUMBER_TYPE:
                if (NumericPicker.SelectedItem == null)
                {
                    return(new NoneMixEvaluator());
                }

                SelectableOption <NumericEvalType> selectedNumericType = DebugHelper.CastAndAssert <SelectableOption <NumericEvalType> >(NumericPicker.SelectedItem);

                string newTarget = ConvertNumericValueToString(selectedType.Type);

                return(MixViewModel.NumericMixEntryModelToMixEvaluator(selectedType.Type | NumericMixEvaluator <int> .NumericEvalTypeToMixTypeVariant(selectedNumericType.Type), newTarget));

            case MixType.STRING_TYPE:
                if (StringPicker.SelectedItem == null)
                {
                    return(new NoneMixEvaluator());
                }

                SelectableOption <StringEvalType> selectedStringType = DebugHelper.CastAndAssert <SelectableOption <StringEvalType> >(StringPicker.SelectedItem);

                return(MixViewModel.StringMixEntryModelToMixEvaluator(selectedType.Type | StringMixEvaluator.StringEvalTypeToMixTypeVariant(selectedStringType.Type), StringValue.Text));

            case MixType.NESTED_TYPE:
                List <IMixEvaluator> mixes = new List <IMixEvaluator>();

                foreach (object listItem in NestedList.Children)
                {
                    MixEntry listItemAsMixEntry = DebugHelper.CastAndAssert <MixEntry>(listItem);

                    mixes.Add(listItemAsMixEntry.ConvertToEvaluator());
                }

                return(MixViewModel.NestedMixEntryModelToMixEvaluator(selectedType.Type, mixes));

            case MixType.RANGE_TYPE:
                return(MixViewModel.RangeMixEntryModelToMixEvaluator(selectedType.Type | RangeMixEvaluator.RangeEvalTypeToMixTypeVariant(RangeEvalType.Days), RangeValue.Text));

            case MixType.MEMBER_TYPE:
                if (selectedType.Type == MixType.PLAYLISTMEMBER_SUBTYPE)
                {
                    if (PlaylistMemberPicker.SelectedItem == null)
                    {
                        return(new NoneMixEvaluator());
                    }

                    PlaylistViewModel selectedPlaylist = DebugHelper.CastAndAssert <PlaylistViewModel>(PlaylistMemberPicker.SelectedItem);

                    return(MixViewModel.MemberMixEntryModelToMixEvaluator(MixType.PlaylistMemberContains, selectedPlaylist.PlaylistId.ToString()));
                }
                else if (selectedType.Type == MixType.MIXMEMBER_SUBTYPE)
                {
                    if (MixMemberPicker.SelectedItem == null)
                    {
                        return(new NoneMixEvaluator());
                    }

                    MixViewModel selectedMix = DebugHelper.CastAndAssert <MixViewModel>(MixMemberPicker.SelectedItem);

                    return(MixViewModel.MemberMixEntryModelToMixEvaluator(MixType.MixMemberContains, selectedMix.MixId.ToString()));
                }
                else
                {
                    DebugHelper.Alert(new CallerInfo(), "Unexpected member type: {0}", selectedType);
                    return(new NoneMixEvaluator());
                }

            default:
                DebugHelper.Assert(new CallerInfo(), selectedType.Type == MixType.None, "Unexpected mix type: {0}", selectedType.Type);
                return(new NoneMixEvaluator());
            }
        }
示例#14
0
        public void LoadEvaluator(IMixEvaluator evaluator)
        {
            MixType mixType = evaluator.MixType;

            SelectableOption <MixType> selectedMixTypeEntry = AllMixTypes.Where((m) => { return(m.Type == (mixType & MixType.SUBTYPE_MASK) || m.Type == mixType); }).FirstOrDefault();

            MixEntryType.SelectedItem = selectedMixTypeEntry;

            switch (mixType & MixType.TYPE_MASK)
            {
            case MixType.NUMBER_TYPE:
                NumericMixEvaluator <IComparable> numericEvaluator = DebugHelper.CastAndAssert <NumericMixEvaluator <IComparable> >(evaluator);

                SelectableOption <NumericEvalType> selectedNumericTypeEntry = NumericInfo.Where((m) => { return(m.Type == numericEvaluator.EvalType); }).FirstOrDefault();
                NumericPicker.SelectedItem = selectedNumericTypeEntry;

                UpdateNumericStartingValue(mixType, numericEvaluator.Target);
                return;

            case MixType.STRING_TYPE:
                StringMixEvaluator stringEvaluator = DebugHelper.CastAndAssert <StringMixEvaluator>(evaluator);

                SelectableOption <StringEvalType> selectedStringTypeEntry = StringInfo.Where((m) => { return(m.Type == stringEvaluator.EvalType); }).FirstOrDefault();
                StringPicker.SelectedItem = selectedStringTypeEntry;

                StringValue.Text = stringEvaluator.Target;
                return;

            case MixType.NESTED_TYPE:
                NestedMixEvaluator nestedEvaluator = DebugHelper.CastAndAssert <NestedMixEvaluator>(evaluator);

                foreach (IMixEvaluator mixEvaluator in nestedEvaluator.Mixes)
                {
                    MixEntry nestedEntry = new MixEntry(this, Depth + 1);
                    nestedEntry.LoadEvaluator(mixEvaluator);
                    NestedList.Children.Add(nestedEntry);
                    nestedEntry.TextBotGotFocus  += HandleTextBoxGotFocus;
                    nestedEntry.TextBotLostFocus += HandleTextBoxLostFocus;
                }

                return;

            case MixType.MEMBER_TYPE:
                MemberMixEvaluator memberEvaluator = DebugHelper.CastAndAssert <MemberMixEvaluator>(evaluator);

                if ((mixType & MixType.SUBTYPE_MASK) == MixType.PLAYLISTMEMBER_SUBTYPE)
                {
                    PlaylistViewModel playlist = LibraryViewModel.Current.LookupPlaylistById(memberEvaluator.Target);

                    PlaylistMemberPicker.SelectedItem = playlist;
                }
                else if ((mixType & MixType.SUBTYPE_MASK) == MixType.MIXMEMBER_SUBTYPE)
                {
                    MixViewModel mix = LibraryViewModel.Current.LookupMixById(memberEvaluator.Target);

                    MixMemberPicker.SelectedItem = mix;
                }
                else
                {
                    DebugHelper.Alert(new CallerInfo(), "Unexpected member type: {0}", mixType);
                    return;
                }

                return;

            case MixType.RANGE_TYPE:
                RangeMixEvaluator rangeEvaluator = DebugHelper.CastAndAssert <RangeMixEvaluator>(evaluator);

                RangeValue.Text = rangeEvaluator.Target.ToString();

                return;

            default:
                DebugHelper.Assert(new CallerInfo(), mixType == MixType.None, "Unexpected mix type: {0}", mixType);
                VisualStateManager.GoToState(this, "UnknownSelected", false);
                return;
            }
        }
示例#15
0
 // Start is called before the first frame update
 public override void Activate(SelectableOption option)
 {
     InventoryHandler.instance.Add(option.createdItem);
     GameHandler.instance.player.GetComponent <PlayerBehavior>().UpdateDamage();
 }