Exemple #1
0
 public void MouseDown()
 {
     StatEvent += ConsoleHi;
     StatEvent.Invoke();
     StatEvent -= ConsoleHi;
     StatEvent.Invoke();
 }
Exemple #2
0
        private void Update()
        {
            EntityBehaviour entityBehaviour = PlayerManager.SpaceShip;
            Stat            stat            = entityBehaviour.Entity.GetStat(m_ModType.Identifier);

            m_OnStatChangeEvent.Invoke(stat);
            return;

            if (m_LastStat == null || !m_LastStat.Equals(stat))
            {
                m_LastStat = stat.Copy();
                if (m_OnStatChangeEvent != null)
                {
                    m_OnStatChangeEvent.Invoke(m_LastStat);
                }
            }
        }
Exemple #3
0
 public virtual bool Reduce(int amount)
 {
     if (current > 0)
     {
         int previous = current;
         current -= amount;
         OnChange?.Invoke(previous, current);
         OnDamage?.Invoke(previous, current);
         if (current <= 0)
         {
             current = 0;
             OnZero?.Invoke(previous, current);
         }
         return(true);
     }
     return(false);
 }
Exemple #4
0
 protected void QuickSet(T value)
 {
     this.value = value;
     if (onSet != null)
     {
         onSet.Invoke(value);
     }
 }
Exemple #5
0
 public virtual bool Increase(int amount)
 {
     if (current < max)
     {
         int previous = current;
         current += amount;
         OnChange?.Invoke(previous, current);
         OnIncrease?.Invoke(previous, current);
         if (current > max)
         {
             current = max;
         }
         return(true);
     }
     return(false);
 }
Exemple #6
0
        public Stat <T> Set(T value, bool applyBuffs = true)
        {
            if (applyBuffs)
            {
                T delta = Sub(this.value, value);
                Set(Add(this.value, ApplyAllBuffs(delta)), false);
                return(this);
            }

            if (value is IComparable)                                               // Can be checked
            {
                if (min != null && (min.CompareTo(value) > 0 || min.Equals(value))) // Check min
                {
                    if (min.CompareTo(value) > 0)
                    {
                        if ((boundMode == BoundMode.MinLoop || boundMode == BoundMode.BidirectionalLoop) && max != null)
                        {
                            QuickSet(Sub(Sub(value, MIN), MAX)); // équivaut à MAX - (MIN - value)
                        }
                        else
                        {
                            QuickSet(MIN);
                        }
                    }
                    else
                    {
                        QuickSet(value);
                    }

                    onMinReached.Invoke(value);
                }
                else if (max != null && (max.CompareTo(value) < 0 || max.Equals(value)))       // Check max
                {
                    if (max.CompareTo(value) < 0)
                    {
                        if ((boundMode == BoundMode.MaxLoop || boundMode == BoundMode.BidirectionalLoop) && min != null)
                        {
                            T newVal0 = Sub(MAX, value);
                            T newVal  = Add(newVal0, MIN);
                            QuickSet(newVal); // équivaut à MIN + (value - MAX)
                        }
                        else
                        {
                            QuickSet(MAX);
                        }
                    }
                    else
                    {
                        QuickSet(value);
                    }
                    onMaxReached.Invoke(value);
                }
                else
                {
                    QuickSet(value);
                }
            }
            else                                                // Cannot be checked
            {
                QuickSet(value);
            }

            return(this);
        }
Exemple #7
0
 void QuickSet(T value)
 {
     this.value = value;
     onSet.Invoke(value);
 }
Exemple #8
0
        public StatNumber <T> Set(T value, bool beforeBuffs)
        {
            if (beforeBuffs)
            {
                T delta = Substract(value, this.value);
                Set(Add(this.value, ApplyAllBuffs(delta)), false); //Applique les buffs au delta
                return(this);
            }


            if (minSet && (min.CompareTo(value) > 0 || min.Equals(value)))            // Check min
            {
                //Min overflow ?
                if (min.CompareTo(value) > 0)
                {
                    if ((boundMode == BoundMode.MinLoop || boundMode == BoundMode.BidirectionalLoop) && maxSet)
                    {
                        T delta = Substract(MIN, value);   // (MIN - value)
                        Set(Substract(MAX, delta), false); // équivaut à MAX - (MIN - value)
                    }
                    else
                    {
                        QuickSet(MIN);
                    }
                }
                else
                {
                    QuickSet(value);
                }

                if (onMinReached != null)
                {
                    onMinReached.Invoke(value);
                }
            }
            else if (maxSet && (max.CompareTo(value) < 0 || max.Equals(value)))       // Check max
            {
                //Max overflow ?
                if (max.CompareTo(value) < 0)
                {
                    if ((boundMode == BoundMode.MaxLoop || boundMode == BoundMode.BidirectionalLoop) && minSet)
                    {
                        T delta = Substract(value, MAX); // value - MAX
                        Set(Add(delta, MIN), false);     // équivaut à MIN + (value - MAX)
                    }
                    else
                    {
                        QuickSet(MAX);
                    }
                }
                else
                {
                    QuickSet(value);
                }

                if (onMaxReached != null)
                {
                    onMaxReached.Invoke(value);
                }
            }
            else
            {
                QuickSet(value);
            }

            return(this);
        }