Exemple #1
0
 public GatherEvent(ResourceTarget r, ResourceGivePair gp, int qty)
 {
     this.res      = r;
     this._qty     = qty;
     this._item    = gp.ResourceItemDataBlock.name;
     this._type    = this.res.type.ToString();
     this.Override = false;
 }
Exemple #2
0
        public GatherEvent(ResourceTarget r, ResourceGivePair gp, int qty)
        {
            Contract.Requires(r != null);
            Contract.Requires(gp != null);
            Contract.Requires(qty >= 0);

            if (gp.ResourceItemDataBlock == null)
                throw new InvalidOperationException("ResourceGivePair's ResourceItemDataBlock property is null.");
            if (gp.ResourceItemDataBlock.name == null)
                throw new InvalidOperationException("ResourceItemDataBlock's name is null.");

            this.res = r;
            this._qty = qty;
            this._item = gp.ResourceItemDataBlock.name;
            this._type = this.res.type.ToString();
            this.Override = false;
        }
Exemple #3
0
        public static void PlayerGather(Inventory rec, ResourceTarget rt, ResourceGivePair rg, ref int amount)
        {
            Magma.Player player = Magma.Player.FindByNetworkPlayer(rec.networkView.owner);
            GatherEvent  ge     = new GatherEvent(rt, rg, amount);

            if (OnPlayerGathering != null)
            {
                OnPlayerGathering(player, ge);
            }
            amount = ge.Quantity;
            if (!ge.Override)
            {
                amount = Mathf.Min(amount, rg.AmountLeft());
            }
            rg._resourceItemDatablock = ge.Item;
            rg.ResourceItemName       = ge.Item;
        }
Exemple #4
0
        public GatherEvent(ResourceTarget r, ResourceGivePair gp, int qty)
        {
            Contract.Requires(r != null);
            Contract.Requires(gp != null);
            Contract.Requires(qty >= 0);

            if (gp.ResourceItemDataBlock == null)
            {
                throw new InvalidOperationException("ResourceGivePair's ResourceItemDataBlock property is null.");
            }
            if (gp.ResourceItemDataBlock.name == null)
            {
                throw new InvalidOperationException("ResourceItemDataBlock's name is null.");
            }

            this.res      = r;
            this._qty     = qty;
            this._item    = gp.ResourceItemDataBlock.name;
            this._type    = this.res.type.ToString();
            this.Override = false;
        }
    public void Subtract(int amount)
    {
        ResourceGivePair resourceGivePair = this;

        resourceGivePair.realAmount = resourceGivePair.realAmount - amount;
    }
Exemple #6
0
 public static void PlayerGather(Inventory rec, ResourceTarget rt, ResourceGivePair rg, ref int amount)
 {
     try
     {
         Fougerite.Player player = Fougerite.Player.FindByNetworkPlayer(rec.networkView.owner);
         GatherEvent ge = new GatherEvent(rt, rg, amount);
         if (OnPlayerGathering != null)
         {
             OnPlayerGathering(player, ge);
         }
         amount = ge.Quantity;
         if (!ge.Override)
         {
             amount = Mathf.Min(amount, rg.AmountLeft());
         }
         rg._resourceItemDatablock = ge.Item;
         rg.ResourceItemName = ge.Item;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }