Beispiel #1
0
 /// <summary>Keeps result inside</summary>
 public Value Divide(ReadOnlyValue divider, bool showMessageAboutNegativeValue = true)
 {
     //if (invalue.get() <= 0)
     //{
     //    if (showMessageAboutNegativeValue)
     //        Debug.Log("Value divide failed");
     //    value = 99999;
     //}
     //else
     Set(rawUIntValue / (float)divider.RawUIntValue);
     return(this);
 }
Beispiel #2
0
 /// <summary>Keeps result inside</summary>
 public Value Multiply(ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     //if (howMuch.get() < 0)
     //{
     //    if (showMessageAboutNegativeValue)
     //        Debug.Log("Value multiply failed");
     //    value = 0;
     //}
     //else
     Set(howMuch.get() * get());
     return(this);
 }
Beispiel #3
0
 //TODO overflow checks?
 public Value Add(ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     if (rawUIntValue + howMuch.RawUIntValue < 0f)
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Value Add-Value failed");
         }
         Set(0);
     }
     else
     {
         rawUIntValue += howMuch.RawUIntValue;
     }
     return(this);
 }
Beispiel #4
0
 public Value Subtract(ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     if (howMuch.RawUIntValue > rawUIntValue)
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Value subtract gave negative result");
         }
         Set(0);
     }
     else
     {
         rawUIntValue -= howMuch.RawUIntValue;
     }
     return(this);
 }
Beispiel #5
0
 /// <summary>Keeps result inside</summary>
 public Value multiply(ReadOnlyValue invalue, bool showMessageAboutNegativeValue = true)
 {
     if (invalue.get() < 0)
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Value multiply failed");
         }
         value = 0;
     }
     else
     {
         set(invalue.get() * this.get());
     }
     return(this);
 }
Beispiel #6
0
 //TODO overflow checks?
 virtual public Value Add(ReadOnlyValue invalue, bool showMessageAboutNegativeValue = true)
 {
     if (value + invalue.RawValue < 0f)
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Value Add-Value failed");
         }
         set(0);
     }
     else
     {
         value += invalue.RawValue;
     }
     return(this);
 }
Beispiel #7
0
 /// <summary>Keeps result inside</summary>
 public Value divide(ReadOnlyValue invalue, bool showMessageAboutNegativeValue = true)
 {
     if (invalue.get() <= 0)
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Value divide failed");
         }
         value = 99999;
     }
     else
     {
         set(this.value / (float)invalue.RawValue);
     }
     return(this);
 }
Beispiel #8
0
 public Value subtract(ReadOnlyValue invalue, bool showMessageAboutNegativeValue = true)
 {
     if (invalue.RawValue > value)
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Value subtract gave negative result");
         }
         set(0);
         return(this);
     }
     else
     {
         value -= invalue.RawValue;
         return(this);
     }
 }
Beispiel #9
0
 /// <summary>
 /// Checks inside. Wouldn't pay if can't. Takes back deposits from bank, if needed
 /// Doesn't pay tax, doesn't register transaction
 /// </summary>
 public bool PayWithoutRecord(Agent whom, ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     if (this.isBiggerOrEqual(howMuch))// It does has enough cash or deposit
     {
         (whom.Cash as Money).Add(howMuch);
         this.Subtract(howMuch);
         return(true);
     }
     else
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Not enough money to pay in Money.payWithoutRecord");
         }
         return(false);
     }
 }
Beispiel #10
0
 public Procent100 Multiply(ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     base.Multiply(howMuch, showMessageAboutNegativeValue);
     clamp100();
     return(this);
 }
Beispiel #11
0
 public Procent100 Divide(ReadOnlyValue divider, bool showMessageAboutOperationFails = true)
 {
     base.Divide(divider, showMessageAboutOperationFails);
     clamp100();
     return(this);
 }
Beispiel #12
0
 public Procent100(ReadOnlyValue numerator, ReadOnlyValue denominator, bool showMessageAboutOperationFails = true) : base(numerator, denominator, showMessageAboutOperationFails)
 {
     clamp100();
 }
Beispiel #13
0
 public Procent100 Subtract(ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     base.Subtract(howMuch, showMessageAboutNegativeValue);
     clamp100();
     return(this);
 }
 /// <summary>
 /// Returns true if bigger than argument + barrier
 /// </summary>
 public bool isBiggerThan(ReadOnlyValue invalue, ReadOnlyValue barrier)
 {
     return(rawUIntValue > invalue.rawUIntValue + barrier.rawUIntValue);
 }
 public Storage(Product inProduct, ReadOnlyValue inAmount) : base(inAmount)
 {
     product = inProduct;
 }
 public bool isSmallerThan(ReadOnlyValue invalue)
 {
     return(this.value < invalue.value);
 }
Beispiel #17
0
 public void Set(ReadOnlyValue invalue)
 {
     rawUIntValue = invalue.RawUIntValue;
 }
 /// <summary>
 /// Returns true if bigger than argument + barrier
 /// </summary>
 public bool isBiggerThan(ReadOnlyValue invalue, ReadOnlyValue barrier)
 {
     return(this.value > invalue.value + barrier.value);
 }
 public bool isSmallerOrEqual(ReadOnlyValue invalue)
 {
     return(rawUIntValue <= invalue.rawUIntValue);
 }
 public bool IsEqual(ReadOnlyValue invalue)
 {
     return(this.value == invalue.value);
 }
 public bool isBiggerThan(ReadOnlyValue invalue)
 {
     return(this.value > invalue.value);
 }
 protected ReadOnlyValue(ReadOnlyValue number)
 {
     value = number.value;
 }
Beispiel #23
0
 //protected
 public Value(ReadOnlyValue number) : base(number)
 {
     //   set(number); // set already have multiplier
 }
 public bool isSmallerOrEqual(ReadOnlyValue invalue)
 {
     return(this.value <= invalue.value);
 }
 public bool isSmallerThan(ReadOnlyValue invalue)
 {
     return(rawUIntValue < invalue.rawUIntValue);
 }
Beispiel #26
0
 public Procent Subtract(ReadOnlyValue howMuch, bool showMessageAboutNegativeValue = true)
 {
     return(base.Subtract(howMuch, showMessageAboutNegativeValue) as Procent);
 }
 public bool isBiggerOrEqual(ReadOnlyValue invalue)
 {
     return(rawUIntValue >= invalue.rawUIntValue);
 }
Beispiel #28
0
 public Procent(ReadOnlyValue numerator, ReadOnlyValue denominator, bool showMessageAboutOperationFails = true)
     : this(numerator.get(), denominator.get(), showMessageAboutOperationFails)
 {
 }
 public bool isBiggerOrEqual(ReadOnlyValue invalue)
 {
     return(this.value >= invalue.value);
 }
 /// <summary>
 /// returns new value
 /// </summary>
 public Storage Multiply(ReadOnlyValue invalue)
 {
     //return new Storage(this.getProduct(), get() * invalue.get());
     multiply(invalue);
     return(this);
 }