Example #1
0
            protected override void OnDeclare()
            {
                GeneratedEvent event1 = Engine.AddStaticEvent <EventHandler>                      ("NonGeneric", Visibility.Public, null, EventImplementations.Standard);
                GeneratedEvent event2 = Engine.AddStaticEvent <EventHandler <EventArgs> >           ("GenericBasic", Visibility.Public, null, EventImplementations.Standard);
                GeneratedEvent event3 = Engine.AddStaticEvent <EventHandler <SpecializedEventArgs> >("GenericSpecialized", Visibility.Public, null, EventImplementations.Standard);
                GeneratedEvent event4 = Engine.AddStaticEvent <SpecialDelegateEventHandler>       ("Special", Visibility.Public, null, EventImplementations.Standard);

                event1.Raiser.Visibility = Visibility.Public;
                event2.Raiser.Visibility = Visibility.Public;
                event3.Raiser.Visibility = Visibility.Public;
                event4.Raiser.Visibility = Visibility.Public;
            }
Example #2
0
        private GeneratedBatchContainer GenerateBatch()
        {
            sequenceId++;
            var evt = new GeneratedEvent
            {
                // If this is the last event generated, mark it as such, so test grains know to report results.
                EventType = (sequenceId != config.EventsInStream)
                        ? GeneratedEvent.GeneratedEventType.Fill
                        : GeneratedEvent.GeneratedEventType.End,
            };

            return(new GeneratedBatchContainer(streamGuid, config.StreamNamespace, evt, new EventSequenceToken(sequenceId)));
        }
Example #3
0
        public static PartInfo Process(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence)
        {
            if (partCountEvent.ValueType == ValueType.CAPTURE_ITEM)
            {
                return(ProcessCaptureItemMethod(partCountEvent, gEvent, _lastSequence));
            }
            else if (partCountEvent.ValueType == ValueType.STATIC_INCREMENT)
            {
                return(ProcessStaticIncrementMethod(partCountEvent, gEvent, _lastSequence));
            }

            return(null);
        }
Example #4
0
    public void InitiateRandomEvent()
    {
        if (Random.Range(0f, 100f) <= eventChance)//checks the eventchance percentage.
        {
            Time.timeScale = 0f;//pauses the passage of time.
            //First we desactivate the rest of the UI so we can't create conflicts.
            GameObject.FindWithTag("UI").transform.FindChild("Tabs").gameObject.SetActive(false);
            GameObject.FindWithTag("UI").transform.FindChild("OverWorld").gameObject.SetActive(false);
            //We select a random event from our list.
            currentEvent = GetRandomEvent();
            eventPanel.transform.FindChild("IMG_Main").GetComponent<Image>().sprite = currentEvent.image;
            eventPanel.transform.FindChild("Txt_Title").GetComponent<Text>().text = currentEvent.title;
            eventPanel.transform.FindChild("Txt_Description").GetComponent<Text>().text = currentEvent.description;

            if (currentEvent.num_Options > 0)
            {
                eventPanel.transform.FindChild("Btn_Option_1").gameObject.SetActive(true);
                eventPanel.transform.FindChild("Btn_Option_1").transform.FindChild("Text").GetComponent<Text>().text = currentEvent.txt_Btn_One;
            }
            else { eventPanel.transform.FindChild("Btn_Option_1").gameObject.SetActive(false); }
            if (currentEvent.num_Options > 1)
            {
                eventPanel.transform.FindChild("Btn_Option_2").gameObject.SetActive(true);
                eventPanel.transform.FindChild("Btn_Option_2").transform.FindChild("Text").GetComponent<Text>().text = currentEvent.txt_Btn_Two;
            }
            else { eventPanel.transform.FindChild("Btn_Option_2").gameObject.SetActive(false); }
            if (currentEvent.num_Options > 2)
            {
                eventPanel.transform.FindChild("Btn_Option_3").gameObject.SetActive(true);
                eventPanel.transform.FindChild("Btn_Option_3").transform.FindChild("Text").GetComponent<Text>().text = currentEvent.txt_Btn_Three;
            }
            else { eventPanel.transform.FindChild("Btn_Option_3").gameObject.SetActive(false); }

            eventPanel.GetComponent<Image>().color = currentEvent.panelColor;

            eventPanel.SetActive(true);
        }
    }
Example #5
0
        private static PartInfo ProcessStaticIncrementMethod(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence)
        {
            long sequence = gEvent.CurrentValue.ChangedSequence;

            // Create new PartInfo object
            var info = new PartInfo();

            info.Id        = Guid.NewGuid().ToString();
            info.Timestamp = gEvent.CurrentValue.Timestamp;
            info.Sequence  = sequence;

            info.Count = partCountEvent.StaticIncrementValue;

            return(info);
        }
Example #6
0
        private static PartInfo ProcessCaptureItemMethod(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence)
        {
            if (!string.IsNullOrEmpty(partCountEvent.CaptureItemLink))
            {
                var captureItem = gEvent.CaptureItems.Find(x => x.Name == partCountEvent.CaptureItemLink);

                if (captureItem != null && captureItem.Sequence > _lastSequence)
                {
                    int count = 0;
                    int.TryParse(captureItem.Value, out count);
                    if (count > 0)
                    {
                        DateTime timestamp = gEvent.CurrentValue.Timestamp;

                        // Create new PartInfo object
                        var info = new PartInfo();
                        info.Id        = Guid.NewGuid().ToString();
                        info.Timestamp = timestamp;
                        info.Sequence  = captureItem.Sequence;

                        // Calculate Increment Value based on CalculationType
                        if (partCountEvent.CalculationType == CalculationType.INCREMENTAL)
                        {
                            info.Count = count;
                        }
                        else if (partCountEvent.CalculationType == CalculationType.TOTAL)
                        {
                            int previousCount = 0;
                            int.TryParse(captureItem.PreviousValue, out previousCount);

                            // If Part Count is less than or equal to stored value then assume
                            // it has been reset and needs to be incremented the entire new amount
                            if (count <= previousCount)
                            {
                                info.Count = count;
                            }
                            else
                            {
                                info.Count = count - previousCount;
                            }
                        }

                        return(info);
                    }
                }
            }

            return(null);
        }