Esempio n. 1
0
    public override float EstimateCost(IWorldState worldState)
    {
        Merchant merchant  = worldState.GetMerchant(merchantId);
        float    salePrice = merchant.saleEntries[saleEntryIndex].price;

        return(salePrice);
    }
Esempio n. 2
0
    protected override void GenerateConditions(IWorldState worldState)
    {
        Merchant merchant = worldState.GetMerchant(merchantId);

        conditions = new List <Condition>();
        MoneyCondition moneyCond = new MoneyCondition(buyerId, merchant.saleEntries[saleEntryIndex].price);

        conditions.Add(moneyCond);
        LocationCondition locationCond = new LocationCondition(buyerId, merchant.position);

        conditions.Add(locationCond);
    }
Esempio n. 3
0
    public override void ExecuteImmediate(IWorldState worldState)
    {
        IEntity  buyer     = worldState.GetEntity(buyerId);
        Merchant merchant  = worldState.GetMerchant(merchantId);
        float    salePrice = merchant.saleEntries[saleEntryIndex].price;

        if (buyer.Money > salePrice)
        {
            Item item = merchant.saleEntries[saleEntryIndex].itemTemplate.Generate();
            buyer.AddInventoryItem(item);
            buyer.Money -= salePrice;
        }
    }
Esempio n. 4
0
 public Merchant GetMerchant(int id)
 {
     if (merchantDict.TryGetValue(id, out Merchant merchant))
     {
         return(merchant);
     }
     else
     {
         Merchant parentMerchant = parentWorldState.GetMerchant(id);
         if (parentMerchant != null)
         {
             Merchant m = parentMerchant.Clone();
             merchantDict.Add(m.id, m);
             return(m);
         }
         else
         {
             return(null);
         }
     }
 }