コード例 #1
0
ファイル: VendorUI.cs プロジェクト: michaelday008/AnyRPGCore
        //protected List<CurrencyAmountController> currencyAmountControllers = new List<CurrencyAmountController>();

        public override void Configure(SystemGameManager systemGameManager)
        {
            base.Configure(systemGameManager);
            playerManager      = systemGameManager.PlayerManager;
            uIManager          = systemGameManager.UIManager;
            messageFeedManager = uIManager.MessageFeedManager;
            currencyConverter  = systemGameManager.CurrencyConverter;

            //vendorUI.CreatePages(items);
            CreateEventSubscriptions();
            //InitializeBuyBackList();
            //buyBackCollection = new VendorCollection();
            buyBackCollection = ScriptableObject.CreateInstance(typeof(VendorCollection)) as VendorCollection;

            currencyBarController.Configure(systemGameManager);
            currencyBarController.SetToolTipTransform(rectTransform);

            foreach (VendorButton vendorButton in vendorButtons)
            {
                vendorButton.Configure(systemGameManager);
            }

            /*
             * foreach (CurrencyAmountController currencyAmountController in currencyAmountControllers) {
             *  currencyAmountController.Configure(systemGameManager);
             * }
             */
        }
コード例 #2
0
ファイル: VendorUI.cs プロジェクト: jon205/AnyRPGAlphaCode
        public bool SellItem(Item item)
        {
            if (item.BuyPrice <= 0 || item.MySellPrice.Key == null)
            {
                MessageFeedManager.MyInstance.WriteMessage("The vendor does not want to buy the " + item.DisplayName);
                return(false);
            }
            KeyValuePair <Currency, int> sellAmount = item.MySellPrice;

            (PlayerManager.MyInstance.MyCharacter as PlayerCharacter).MyPlayerCurrencyManager.AddCurrency(sellAmount.Key, sellAmount.Value);
            AddToBuyBackCollection(item);
            //InventoryManager.MyInstance.RemoveItem(item);
            item.MySlot.RemoveItem(item);

            if (SystemConfigurationManager.MyInstance.VendorAudioProfile != null && SystemConfigurationManager.MyInstance.VendorAudioProfile.AudioClip != null)
            {
                AudioManager.MyInstance.PlayEffect(SystemConfigurationManager.MyInstance.VendorAudioProfile.AudioClip);
            }
            string priceString = CurrencyConverter.GetCombinedPriceSring(sellAmount.Key, sellAmount.Value);

            MessageFeedManager.MyInstance.WriteMessage("Sold " + item.DisplayName + " for " + priceString);


            if (dropDownIndex == 0)
            {
                CreatePages(vendorCollections[dropDownIndex].MyVendorItems);
                LoadPage(pageIndex);
                OnPageCountUpdate(false);
            }
            return(true);
        }
コード例 #3
0
        public override void SetGameManagerReferences()
        {
            base.SetGameManagerReferences();

            objectPooler      = systemGameManager.ObjectPooler;
            playerManager     = systemGameManager.PlayerManager;
            currencyConverter = systemGameManager.CurrencyConverter;
        }
コード例 #4
0
        public static KeyValuePair <Sprite, string> RecalculateValues(List <CurrencyNode> usedCurrencyNodes, bool setIcon = true)
        {
            //Debug.Log("CurrencyConverter.RecalculateValues()");
            Sprite        returnSprite  = null;
            List <string> returnStrings = new List <string>();
            Dictionary <Currency, CurrencyNode> squishedNodes = new Dictionary <Currency, CurrencyNode>();

            foreach (CurrencyNode currencyNode in usedCurrencyNodes)
            {
                if (currencyNode.currency != null)
                {
                    if (squishedNodes.ContainsKey(currencyNode.currency))
                    {
                        CurrencyNode tmp = squishedNodes[currencyNode.currency];
                        tmp.MyAmount += currencyNode.MyAmount;
                        squishedNodes[currencyNode.currency] = tmp;
                    }
                    else
                    {
                        CurrencyNode tmp = new CurrencyNode();
                        tmp.currency = currencyNode.currency;
                        tmp.MyAmount = currencyNode.MyAmount;
                        squishedNodes.Add(tmp.currency, tmp);
                    }
                }
            }
            if (squishedNodes.Count > 0)
            {
                //Debug.Log("LootableDrop.RecalculateValues(): squishedNodes.count: " + squishedNodes.Count);
                bool nonZeroFound = false;
                foreach (KeyValuePair <Currency, int> keyValuePair in CurrencyConverter.RedistributeCurrency(squishedNodes.ElementAt(0).Value.currency, squishedNodes.ElementAt(0).Value.MyAmount))
                {
                    if (keyValuePair.Value > 0 && nonZeroFound == false)
                    {
                        nonZeroFound = true;
                        if (setIcon)
                        {
                            //Debug.Log("LootableDrop.RecalculateValues(): setting icon: " + keyValuePair.Key.MyIcon.name);
                            returnSprite = keyValuePair.Key.Icon;
                        }
                    }
                    if (nonZeroFound == true)
                    {
                        returnStrings.Add(keyValuePair.Value + " " + keyValuePair.Key.DisplayName);
                    }
                }
            }

            //Debug.Log("LootableDrop.RecalculateValues(): " + summary);
            return(new KeyValuePair <Sprite, string>(returnSprite, string.Join("\n", returnStrings)));
        }
コード例 #5
0
        public void UpdateCurrencyAmount(Currency currency, int currencyAmount, string priceString)
        {
            //Debug.Log(gameObject.name + ".CurrencyBarController.UpdateCurrencyAmount(" + currency.DisplayName + ", " + currencyAmount + ", " + priceString + ")");

            Dictionary <Currency, int> currencyList = CurrencyConverter.RedistributeCurrency(currency, currencyAmount);

            ClearCurrencyAmounts();
            // spawn new ones

            if (priceText != null)
            {
                if (priceString != string.Empty)
                {
                    priceText.gameObject.SetActive(true);
                    priceText.text = priceString;
                }
            }
            int counter = 0;

            foreach (KeyValuePair <Currency, int> currencyPair in currencyList)
            {
                //Debug.Log(gameObject.name + ".CurrencyBarController.UpdateCurrencyAmount(" + currency.MyName + ", " + currencyAmount + "): currencyPair.Key: " + currencyPair.Key + "; currencyPair.Value: " + currencyPair.Value);
                //GameObject go = Instantiate(currencyAmountPrefab, currencyAmountParent.transform);
                //go.transform.SetAsFirstSibling();
                //CurrencyAmountController currencyAmountController = go.GetComponent<CurrencyAmountController>();
                //currencyAmountControllers.Add(currencyAmountController);
                if (currencyAmountControllers.Count > counter)
                {
                    CurrencyAmountController currencyAmountController = currencyAmountControllers[counter];
                    currencyAmountController.gameObject.SetActive(true);
                    if (currencyAmountController.MyCurrencyIcon != null)
                    {
                        currencyAmountController.MyCurrencyIcon.SetDescribable(currencyPair.Key);
                    }
                    if (currencyAmountController.MyAmountText != null)
                    {
                        currencyAmountController.MyAmountText.text = currencyPair.Value.ToString();
                    }
                }
                counter += 1;
            }
        }
コード例 #6
0
        public void ShowDescription(Quest quest)
        {
            //Debug.Log("QuestDetailsArea.ShowDescription()");

            ClearDescription();

            if (quest == null)
            {
                return;
            }
            this.quest = quest;

            questDescription.text = quest.GetObjectiveDescription();

            experienceReward.text += LevelEquations.GetXPAmountForQuest(PlayerManager.MyInstance.MyCharacter.CharacterStats.Level, quest) + " XP";

            // display currency rewards

            List <CurrencyNode> currencyNodes = quest.GetCurrencyReward();

            // currencies could be different
            if (currencyNodes.Count > 0)
            {
                currencyHeading.gameObject.SetActive(true);
                currencyArea.gameObject.SetActive(true);
                if (currencyLootButton != null)
                {
                    KeyValuePair <Sprite, string> keyValuePair = CurrencyConverter.RecalculateValues(currencyNodes, true);
                    currencyLootButton.MyIcon.sprite = keyValuePair.Key;
                    currencyLootButton.MyTitle.text  = keyValuePair.Value;
                }
            }
            else
            {
                currencyHeading.gameObject.SetActive(false);
                currencyArea.gameObject.SetActive(false);
            }


            // show item rewards
            if (quest.MyItemRewards.Count > 0)
            {
                itemsHeading.gameObject.SetActive(true);
                if (quest.MyMaxItemRewards > 0)
                {
                    itemsHeading.GetComponent <TextMeshProUGUI>().text = "Choose " + quest.MyMaxItemRewards + " Item Rewards:";
                }
                else
                {
                    itemsHeading.GetComponent <TextMeshProUGUI>().text = "Item Rewards:";
                }
            }
            for (int i = 0; i < quest.MyItemRewards.Count; i++)
            {
                RewardButton rewardIcon = Instantiate(rewardIconPrefab, itemIconsArea.transform).GetComponent <RewardButton>();
                rewardIcon.OnAttempSelect += HandleAttemptSelect;
                //Debug.Log("QuestDetailsArea.ShowDescription(): setting describable (and attemptselect) for: " + quest.MyItemRewards[i]);
                rewardIcon.SetDescribable(quest.MyItemRewards[i]);
                itemRewardIcons.Add(rewardIcon);
            }

            // show ability rewards
            if (quest.MyAbilityRewards.Count > 0)
            {
                abilitiesHeading.gameObject.SetActive(true);
                if (quest.MyMaxAbilityRewards > 0)
                {
                    abilitiesHeading.GetComponent <TextMeshProUGUI>().text = "Choose " + quest.MyMaxAbilityRewards + " Ability Rewards:";
                }
                else
                {
                    abilitiesHeading.GetComponent <TextMeshProUGUI>().text = "Ability Rewards:";
                }
            }
            else
            {
                abilitiesHeading.GetComponent <TextMeshProUGUI>().text = "";
            }
            for (int i = 0; i < quest.MyAbilityRewards.Count; i++)
            {
                RewardButton rewardIcon = Instantiate(rewardIconPrefab, abilityIconsArea.transform).GetComponent <RewardButton>();
                rewardIcon.OnAttempSelect += HandleAttemptSelect;
                //Debug.Log("QuestDetailsArea.ShowDescription(): setting describable (and attemptselect) for: " + quest.MyAbilityRewards[i]);
                rewardIcon.SetDescribable(quest.MyAbilityRewards[i]);
                abilityRewardIcons.Add(rewardIcon);
            }

            // show faction rewards
            if (quest.MyFactionRewards.Count > 0)
            {
                factionsHeading.gameObject.SetActive(true);
                if (quest.MyMaxFactionRewards > 0)
                {
                    factionsHeading.GetComponent <TextMeshProUGUI>().text = "Choose " + quest.MyMaxFactionRewards + " Reputation Rewards:";
                }
                else
                {
                    factionsHeading.GetComponent <TextMeshProUGUI>().text = "Reputation Rewards:";
                }
            }
            else
            {
                factionsHeading.GetComponent <TextMeshProUGUI>().text = "";
            }
            for (int i = 0; i < quest.MyFactionRewards.Count; i++)
            {
                FactionRewardButton rewardIcon = Instantiate(factionRewardIconPrefab, factionIconsArea.transform).GetComponent <FactionRewardButton>();
                rewardIcon.OnAttempSelect += HandleAttemptSelect;
                //Debug.Log("QuestDetailsArea.ShowDescription(): setting describable (and attemptselect) for: " + quest.MyFactionRewards[i]);
                rewardIcon.SetDescribable(quest.MyFactionRewards[i]);
                factionRewardIcons.Add(rewardIcon);
            }

            // show Skill rewards
            if (quest.MySkillRewards.Count > 0)
            {
                skillHeading.gameObject.SetActive(true);
                if (quest.MyMaxSkillRewards > 0)
                {
                    skillHeading.GetComponent <TextMeshProUGUI>().text = "Choose " + quest.MyMaxSkillRewards + " Skill Rewards:";
                }
                else
                {
                    skillHeading.GetComponent <TextMeshProUGUI>().text = "Skill Rewards:";
                }
            }
            else
            {
                skillHeading.GetComponent <TextMeshProUGUI>().text = "";
            }
            for (int i = 0; i < quest.MySkillRewards.Count; i++)
            {
                RewardButton rewardIcon = Instantiate(rewardIconPrefab, skillIconsArea.transform).GetComponent <RewardButton>();
                rewardIcon.SetDescribable(quest.MySkillRewards[i]);
                skillRewardIcons.Add(rewardIcon);
            }
        }
コード例 #7
0
 public override void SetGameManagerReferences()
 {
     base.SetGameManagerReferences();
     currencyConverter = systemGameManager.CurrencyConverter;
 }