Esempio n. 1
0
        public MerchantView(Merchant merchant, MainWindow window)
        {
            InitializeComponent();
            this.merchant = merchant;
            this.window = window;

            merchantItems.SetItems(merchant.MerchantItems);
            playerItems.SetItems(merchant.Player.Inventory);

            playerNameLabel.Text = merchant.Player.Name;
            merchantLabel.Text = merchant.GetName();
            goldLabel.Text = "Gold: " + merchant.Player.Gold.ToString();

            playerItems.CanAddItem += PlayerItems_CanAddItem;
            playerItems.AddItem += PlayerItems_AddItem;
            playerItems.RemoveItem += PlayerItems_RemoveItem;
            merchantItems.RemoveItem += MerchantItems_RemoveItem;
            merchantItems.AddItem += MerchantItems_AddItem;
            UINotifier.Get().OnPlayerInventoryUpdated += MerchantView_OnPlayerInventoryUpdated;
        }
Esempio n. 2
0
 public IEncounter GetEncounter()
 {
     int random = GetRandom(10);
     if (random < 2)
     {
         return new Treasure(this, Player);
     }
     else if (random < 3 && CurrentLocation.Encounters.Count < 3)
     {
         Merchant merchant = new Merchant(this, Player);
         CurrentLocation.Encounters.Add(merchant);
         return merchant;
     }
     Monster enemy = monsterManager.GetEnemyForLocation(CurrentLocation);
     return new Fight(this, Player, enemy);
 }