Exemplo n.º 1
0
    public bool CheckConditionsEvent(TriggerContent theEvent)
    {
        bool validated = true;

        if (theEvent.conditionNames.Count == 0)
        {
            return(validated);
        }
        else
        {
            for (int i = 0; i < theEvent.conditionNames.Count; i++)
            {
                switch (theEvent.conditionNames[i])
                {
                case "Counter>=threshold":
                    validated &= myData.allCounters[theEvent.conditionData[i]].count >= theEvent.conditionValues[i];
                    break;

                case "Counter<threshold":
                    validated &= myData.allCounters[theEvent.conditionData[i]].count < theEvent.conditionValues[i];
                    break;
                }
            }
            return(validated);
        }
    }
Exemplo n.º 2
0
        private void lstCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            grd.Children.Clear();
            MyComboItem sel = lstCombo.SelectedItem as MyComboItem;
            RichTextBox rc  = new RichTextBox();

            grd.Children.Add(rc);
            content = sel.getConstructable().construct();
            TriggerDefinitionPartProperties def = new TriggerDefinitionPartProperties(() => KeepDefault);

            def.HideCheckBox = true;
            def.g            = rc;
            Trigger.regenerateTextboxForTriggerDefinitionParts(def, content.getDefinitionParts, (RichTextBox rb) => { rc = rb; });
        }
Exemplo n.º 3
0
        public GeneralTriggerContentInternalCalculator(Parser parser, string name, TriggerContentTypeDescriptor[] types, int[] usefulMapping, int[] atextMapping, int[] trigMapping, Func <TriggerContentTypeDescriptor[], int> getArgCount, TriggerContent content)
        {
            int count   = getArgCount(types);
            int counter = 0;

            _textMapping = atextMapping;

            _contents   = new SaveableItem[count];
            _name       = name;
            visualParts = new TriggerDefinitionPart[types.Length];
            for (int i = 0; i < types.Length; i++)
            {
                int localCounter = counter;
                TriggerContentTypeDescriptor type = types[i];
                if (type is TriggerContentTypeDescriptorVisual)
                {
                    string label = ((TriggerContentTypeDescriptorVisual)type).Content;
                    if (label.Equals("\n"))
                    {
                        visualParts[i] = new TriggerDefinitionNewLine();
                    }
                    else
                    {
                        visualParts[i] = (TriggerDefinitionPart)TriggerContentType.VISUAL_LABEL(label).Read(null, 0);
                    }
                }
                else
                {
                    _contents[_textMapping[counter]] = type.Read(content, _textMapping[counter]);
                    counter++;
                    visualParts[i] = type.GetDefinitionPart(() => _contents[_textMapping[localCounter]], (SaveableItem whatevs) => { _contents[_textMapping[localCounter]] = whatevs; });
                }
            }
        }
Exemplo n.º 4
0
    public void ResolveEvent(TriggerContent theEvent, GameObject target)
    {
        for (int i = 0; i < theEvent.effectNames.Count; i++)
        {
            string theText;

            switch (theEvent.effectNames[i])
            {
            // COMMENTARY EVENTS
            case "Pool_commentary":
                aBag = new WeightedBag();
                for (int j = 0; j < theEvent.effectData.Count; j++)
                {
                    aBag.AddElement(theEvent.effectData[j], theEvent.effectValues[j] / 100f);
                }

                theText = aBag.Draw(true);
                if (theText != "nothing")
                {
                    target.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text += theText + "\n"; target.SetActive(true);
                }
                else
                {
                    target.SetActive(false);
                }
                break;

            case "Commentary":
                target.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text += theEvent.effectData[i] + "\n";
                target.SetActive(true);
                break;

            case "Commentary_Variable":
                List <string> copyText = new List <string>(); theEvent.effectData.ForEach(x => copyText.Add(x));
                theText = DecodeString(copyText);
                target.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text += theText + "\n";

                target.SetActive(true);
                break;

            case "Increment_counter":
                myData.allCounters[theEvent.effectData[i]].count += (int)theEvent.effectValues[i];
                myData.StoreCounters();

                ExecuteFromTrigger("Incremented_" + theEvent.effectData[i], target);
                break;

            case "Set_counter":
                myData.allCounters[theEvent.effectData[i]].count = (int)theEvent.effectValues[i];
                myData.StoreCounters();
                break;

            // EVENTS
            case "Special_Event":
                eventData = theEvent.effectData;
                GetComponent <GameHandler>().specialEvent = true;
                break;

            case "Force_encounter":
                CharacterContent encounter = new CharacterContent(myData.allMobs[theEvent.effectData[i]]);

                encounter.myName = theEvent.effectData[i + 1];   // dangerous... an encounter can be force-set without name change
                GetComponent <ConfrontationHandler>().forceEncounter = encounter;
                break;

            case "Force_loot":
                GetComponent <LootHandler>().forceLoot = theEvent.effectData[i];
                break;

            case "Pool_triggerEvent":
                aBag = new WeightedBag();
                for (int j = 0; j < theEvent.effectData.Count; j++)
                {
                    aBag.AddElement(theEvent.effectData[j], theEvent.effectValues[j] / 100f);
                }

                theText = aBag.Draw(true);
                ResolveEvent(myData.allEvents[theText], target);
                break;

            // TOOLS
            case "Activate":
                SetEventActive(theEvent.effectData[i], true);
                break;

            case "Deactivate":
                SetEventActive(theEvent.effectData[i], false);
                break;

            case "Deactivate_quest":
                foreach (string elt in myData.allEvents.Keys.ToList())
                {
                    if (elt.Contains(theEvent.effectData[i]))
                    {
                        SetEventActive(elt, false);
                    }
                }
                break;

            case "Unlock_enemy":
                UnlockEnemy(theEvent.effectData[i]);
                break;

            case "Unlock_item":
                UnlockItem(theEvent.effectData[i]);
                break;
            }
        }
    }