예제 #1
0
        /// <summary>
        /// Adds an affect into the list if it does not exist or updates an existing one.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="modifies"></param>
        /// <param name="modifier"></param>
        /// <param name="duration"></param>
        public void AddOrUpdateAffect(string name, string modifies, int modifier, int duration)
        {
            // Get the affect if it exists.
            var  a   = this.Affects.Find(x => x.Name.Equals(name, System.StringComparison.Ordinal));
            bool add = false;

            // If it doesn't exist, create a new one.
            if (a == null)
            {
                add = true;
                a   = new Affect();
            }

            // Set or update the values.
            a.Name     = name;
            a.Modifies = modifies;
            a.Modifier = modifier;
            a.Duration = duration;

            // Add the affect into our saved list if it wasn't already there.  Otherwise, the
            // reference has been updated.
            if (add)
            {
                this.Affects.Add(a);
            }

            this.UpdateUI();
        }
예제 #2
0
        /// <summary>
        /// Adds an affect into the list whether it exists or not.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="modifies"></param>
        /// <param name="modifier"></param>
        /// <param name="duration"></param>
        public void AddAffect(string name, string modifies, int modifier, int duration)
        {
            // Create the affect.
            var a = new Affect
            {
                Name     = name,
                Modifies = modifies,
                Modifier = modifier,
                Duration = duration
            };

            // Add the affect into our saved list.
            this.Affects.Add(a);

            this.UpdateUI();
        }
예제 #3
0
        public override void Execute()
        {
            if (Match == null)
            {
                return;
            }

            // Create the affect.
            var a = new Affect
            {
                Name     = Match.Groups[2].Value.Trim(),
                Modifies = Match.Groups[3].Value.Trim(),
                Modifier = int.Parse(Match.Groups[4].Value),
                Duration = int.Parse(Match.Groups[5].Value)
            };

            // Add the affect into our saved list.
            this.Affects.Add(a);

            // Update the UI.
            this.UpdateUI();
        }
        public override void Execute()
        {
            if (Match == null)
            {
                return;
            }

            // Create the affect.
            var a = new Affect
            {
                Name     = Match.Groups[2].Value.Trim(),
                Modifies = Match.Groups[3].Value.Trim(),
                Modifier = int.Parse(Match.Groups[4].Value),
                Duration = -1
            };

            // Add it to the list on the main affects trigger.
            if (this.AffectsTrigger != null)
            {
                this.AffectsTrigger.Affects.Add(a);
                this.AffectsTrigger.UpdateUI();
            }
        }