Beispiel #1
0
    void OnEnable()
    {
        audioSource = GetComponent <AudioSource>();
        audioSource.PlayOneShot(menuAppear);
        mgr = FindObjectOfType <CustomisationManager>();
        NewItem currPurchaseItem = mgr.features[mgr.currFeature].ReturnItem();

        itemNameText.text = currPurchaseItem.GetName() + " for " + currPurchaseItem.GetCost() + " orbs?";
    }
Beispiel #2
0
    public void BuyItem()
    {
        NewItem item = features[currFeature].ReturnItem();
        string  key  = item.GetName();

        PlayerPrefs.SetInt(key, 1);
        int totalOrbs = PlayerPrefs.GetInt("ORBS");

        PlayerPrefs.SetInt("ORBS", totalOrbs - item.GetCost());
    }
Beispiel #3
0
    public void UpdateText()
    {
        Feature currFeature = mgr.features[mgr.currFeature];
        NewItem currItem    = currFeature.ReturnItem();

        itemName.text    = currItem.GetName();
        cost.text        = currItem.GetCost().ToString();
        description.text = currItem.GetDescription();

        playerFundsText.text = PlayerPrefs.GetInt("ORBS").ToString();
    }
        /// <summary>
        /// Loads a ItemStack from the file location
        /// </summary>
        /// <param string="FileLoc"></param>
        public void LoadFromFile(string FileLoc)
        {
            try
            {
                if (System.IO.File.Exists(FileLoc))
                {
                    string[] lines = System.IO.File.ReadAllLines(FileLoc);

                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (lines[i].Contains("( ["))
                        {
                            ValueCategory NewCat = new ValueCategory();
                            NewCat.Name       = lines[i].Replace(lines[i].Substring(0, lines[i].IndexOf(" : ") + 3), "").Replace(" ) { ", "");
                            NewCat.ValueStack = new List <FIItems>();
                            ItemStack.Add(NewCat);

                            int InnerI = i + 1;
                            while (lines[InnerI] != "}")
                            {
                                string ValueType = lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf("(") + 1), "").Substring(0, lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf("(") + 1), "").IndexOf(")"));

                                FIItems NewItem = new StringValue("", "");

                                if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.STR])
                                {
                                    NewItem = new StringValue(
                                        lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").Substring(0, lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").IndexOf(" = ")), "");
                                }
                                if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.INT])
                                {
                                    NewItem = new IntValue(
                                        lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").Substring(0, lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").IndexOf(" = ")), 0);
                                }
                                if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.BOL])
                                {
                                    NewItem = new BoolValue(
                                        lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").Substring(0, lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").IndexOf(" = ")), false);
                                }
                                if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.BRS])
                                {
                                    NewItem = new BrushValue(
                                        lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").Substring(0, lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").IndexOf(" = ")), System.Windows.Media.Brushes.White);
                                }
                                if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.DAT])
                                {
                                    NewItem = new DateTimeValue(
                                        lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").Substring(0, lines[InnerI].Replace(lines[InnerI].Substring(0, lines[InnerI].IndexOf(":") + 2), "").IndexOf(" = ")), System.DateTime.Now);
                                }
                                if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.LST])
                                {
                                    NewItem = new ListValue("", "");
                                }
                                else
                                {
                                    if (ValueType == ValueTypesStrings[(int)ValueTypesEnum.ELS])
                                    {
                                        NewItem = new EndListValue("", "");
                                    }
                                    else
                                    {
                                        if (CutStringTillData(lines[InnerI]).StartsWith("R["))
                                        {
                                            NewItem.SetValue(GetValueFromDataPoint(CutStringTillData(lines[InnerI])));
                                        }
                                        else
                                        {
                                            NewItem.SetValue(CutStringTillData(lines[InnerI]));
                                        }
                                    }
                                }

                                if (NewItem.GetName() != "" && NewItem.GetValue() != "")
                                {
                                    NewCat.ValueStack.Add(NewItem);
                                }

                                InnerI++;
                            }
                            i = InnerI;
                        }
                    }
                }
            }
            catch { }
        }