Beispiel #1
0
 /**
  * create items outside the database, if necessary
  */
 public PraeItem(string name, float weightSingle, Currency value, Sprite icon, bool sellable = true, int amount = 1, int stackSize = 1)
 {
     this.name = name;
     this._weightSingle = weightSingle;
     this.value = value;
     this._amount = amount;
     this._stackSize = stackSize;
     this.sellable = sellable;
     this._icon = (icon) ? icon : Managers.XmlDBManager.NotSetIcon;
 }
Beispiel #2
0
 public PraeWeapon(string name, float weightSingle, Currency value, Sprite icon, EGearType gearType, bool sellable = true, int amount = 1, int stackSize = 1)
     : base(name, weightSingle, value, icon, gearType, sellable, amount, stackSize)
 {
 }
Beispiel #3
0
 public void Set(Currency a)
 {
     _G = a.G;
     _K = a.K;
     _T = a.T;
 }
Beispiel #4
0
 public Currency(Currency a)
     : this()
 {
     Set(a);
 }
Beispiel #5
0
        /**
         * remove a from this instance, as long as values do not get negative
         * @RETURN: FALSE, if the amount a cannot be paid (this.relative < a.relative)
         */
        public bool Pay(Currency a)
        {
            if (CanPay(a))
            {
                /*
                _G = System.Math.Max(_G - a.G, 0);
                a.K += System.Math.Max((a.G - _G) * 10, 0); // add the excess if a.G was greater than _G | if (G-a.G) < 0 -> -10*(G-a.G) = 10*(a.G-G)
                _K = System.Math.Max(_K - a.K, 0);
                a.T += System.Math.Max((a.K - _K) * 10, 0); // add the excess if a.K was greater than _K
                _T -= a.T;
                System.Diagnostics.Debug.Assert(_T >= 0, "CanPay or Pay calculation invalid!");
                */
                // partition based on relative
                relative -= a.relative;
                UnityEngine.Debug.Assert(relative >= 0, "something went wring during pay calculation!");

                return true;
            }
            else
                return false;
        }
Beispiel #6
0
 public bool Equals(Currency c)
 {
     return _G == c._G && _K == c._K && _T == c._T;
 }
Beispiel #7
0
 /**
  * returns TRUE, if this.relative >= a.relative
  */
 public bool CanPay(Currency a)
 {
     return relative >= a.relative;
 }
Beispiel #8
0
 public void Add(Currency a)
 {
     _G += a.G;
     _K += a.K;
     _T += a.T;
 }
Beispiel #9
0
 /**
  * be careful with this one! Currencies must never be negative!
  * return a - b as a new currency instance as long as a - b < 0 is false
  */
 public static Currency operator -(Currency a, Currency b)
 {
     Currency a_copy = new Currency(a); // use this instance as base
                                        // n.Pay() subtracts a from this instance if possible. It will return TRUE,
                                        // if subtraction was applied on 'n'. FALSE returns shall throw an error
     System.Diagnostics.Debug.Assert(a_copy.Pay(b), "Cannot subtract currencies from another: result would be negative!");
     return a_copy;
 }
Beispiel #10
0
 public virtual void Set(PraeItem it)
 {
     _id = it._id;
     name = it.name;
     desc = it.desc;
     _weightSingle = it._weightSingle;
     value = it.value;
     _amount = it._amount;
     _stackSize = it._stackSize;
     sellable = it.sellable;
     _icon = it._icon;
 }