public void NewPopupMerchant(Character character, AlignmentMerchant alignment, InventoryItemType type, bool isBuying, System.Func <List <InventoryItem>, object> resultAction, List <InventoryItem> itemsForSale) { var tmpPopupObject = Resources.Load <GameObject>("Prefabs/PopupMerchant"); var tmpPopupInstance = Instantiate(tmpPopupObject, tmpPopupObject.transform.position, tmpPopupObject.transform.rotation); Constants.IncreaseInputLayer(tmpPopupInstance.name); tmpPopupInstance.GetComponent <PopupMerchantBhv>().SetPrivates(character, alignment, type, isBuying, resultAction, itemsForSale); }
public int GetPrice(Character character, bool isBuying, AlignmentMerchant alignment, int merchantDeal) { int levelAdd = (BasePrice / 3) * (character.Level - 1); int rarityAdd = 0; if (Rarity == Rarity.Magical) { rarityAdd = (int)(BasePrice * 2f); } else if (Rarity == Rarity.Rare) { rarityAdd = (int)(BasePrice * 3.5f); } int finalPrice = BasePrice + levelAdd; if (InventoryItemType == InventoryItemType.Weapon) { finalPrice += rarityAdd; } finalPrice += _weaponRandomPriceAdd == -1 ? (_weaponRandomPriceAdd = Random.Range(1, BasePrice / 5)) : _weaponRandomPriceAdd; if (isBuying) { float alignmentPercent = 1.0f; if (alignment == AlignmentMerchant.Fraudulent) { alignmentPercent = Helper.MultiplierFromPercent(1, BiomesData.MerchentPriceBonusPercent); } else if (alignment == AlignmentMerchant.OnSale) { alignmentPercent = Helper.MultiplierFromPercent(1, -BiomesData.MerchentPriceBonusPercent); } float merchantDealBuyPercent = Helper.MultiplierFromPercent(1, -merchantDeal); return((int)(finalPrice * alignmentPercent * merchantDealBuyPercent)); } else { float multiplier = 1.0f; if (alignment == AlignmentMerchant.Fraudulent) { multiplier = Helper.MultiplierFromPercent(1, -BiomesData.MerchentPriceBonusPercent); } else if (alignment == AlignmentMerchant.OnSale) { multiplier = Helper.MultiplierFromPercent(1, BiomesData.MerchentPriceBonusPercent); } float merchantDealSellPercent = Helper.MultiplierFromPercent(1, merchantDeal); return((int)((finalPrice / 5) * multiplier * merchantDealSellPercent)); } }
public void SetPrivates(Character character, AlignmentMerchant alignment, InventoryItemType type, bool isBuying, System.Func <List <InventoryItem>, object> afterManageAction, List <InventoryItem> itemsForSale) { _isBuying = isBuying; _alignment = alignment; _soul = PlayerPrefsHelper.GetSoul(); _character = character; _merchantType = type; _afterManageAction = afterManageAction; _selectedItem = 0; _selectedSprite = transform.Find("SelectedSprite").gameObject; _resetTabPosition = new Vector3(-10.0f, -10.0f, 0.0f); _currentTabPosition = transform.position; _tabs = new List <GameObject>(); _instantiator = GameObject.Find(Constants.GoSceneBhvName).GetComponent <SceneBhv>().Instantiator; for (int i = 0; i < 3; ++i) { _tabs.Add(transform.Find("Tab" + ((InventoryItemType)i).ToString()).gameObject); } _buttonPositive = transform.Find("ButtonPositive").GetComponent <ButtonBhv>().gameObject; _buttonPositiveText = _buttonPositive.transform.GetChild(0).GetComponent <TMPro.TextMeshPro>(); _weightText = transform.Find("Weight").GetComponent <TMPro.TextMeshPro>(); _priceText = transform.Find("ItemPrice").GetComponent <TMPro.TextMeshPro>(); _playerGoldText = transform.Find("PlayerGold").GetComponent <TMPro.TextMeshPro>(); _buttonPriceNPositivePosition = new List <Vector3>(); _buttonPriceNPositivePosition.Add(_priceText.transform.position); _buttonPriceNPositivePosition.Add(_buttonPositive.transform.position); if (_isBuying) { if (itemsForSale == null) { _itemsForSale = PopulateItemsForSale(type); } else { _itemsForSale = itemsForSale; } _items = _itemsForSale; _itemsInventoryPlace = _itemsForSale.Count; } else { _itemsForSale = itemsForSale; _items = _character.Inventory; _itemsInventoryPlace = _character.InventoryPlace; } SetButtons(); }
public override void SetPrivates(int id, int day, Biome biome, Character character, Instantiator instantiator) { base.SetPrivates(id, day, biome, character, instantiator); _cacheSpriteRenderer.sprite = Helper.GetSpriteFromSpriteSheet("Sprites/SwipeCardCache_" + biome.MapType.GetHashCode()); _merchantId = Random.Range(0, BiomesData.MerchantNames.Length); _inventoryItemType = (InventoryItemType)Random.Range(0, Helper.EnumCount <InventoryItemType>()); _alignmentMerchant = AlignmentMerchant.Honest; if (Random.Range(0, 100) < biome.FraudulentMerchantPercentage) { _alignmentMerchant = AlignmentMerchant.Fraudulent; } else if (Random.Range(0, 100) < biome.OnSaleMerchantPercentage) { _alignmentMerchant = AlignmentMerchant.OnSale; } _minutesNeededAvoid = 20; DisplayStats(); }