Exemplo n.º 1
0
    public void WeaponRandomize()
    {
        string[] GetData = GenerateStores.Instance.WeaponSpec.text.Split('\n');
        WpnLot   newItem = new WpnLot();

        newItem.Skin      = Random.Range(1, 11);
        newItem.Condition = Random.Range(1, 11);
        newItem.Name      = GetData[3 * (newItem.Skin - 1)];
        newItem.Name      = newItem.Name.Substring(0, newItem.Name.Length - 1);
        newItem.Damage    = int.Parse(GetData[3 * newItem.Skin - 2]);
        newItem.Price     = newItem.Condition * int.Parse(GetData[3 * newItem.Skin - 1]);
        Lot2.Add(newItem);
    }
Exemplo n.º 2
0
    //======================================================= SAVE STORE ITEMS ===========================================================

    public void SaveStoresInfo()
    {
        if (File.Exists(Application.persistentDataPath + "/StoresStack.json"))
        {
            string     GetInfo    = File.ReadAllText(Application.persistentDataPath + "/StoresStack.json");
            StoreStack StoresInfo = JsonUtility.FromJson <StoreStack>(GetInfo);
            int        StoreID    = PlayInv.StoreID;

            foreach (StorePoint Store in StoresInfo.storePoint)
            {
                if (Store.StoreID == StoreID)
                {
                    Store.Lot1.Clear();
                    Store.Lot2.Clear();
                    Store.Lot3.Clear();
                    Store.Lot4.Clear();
                    foreach (GameObject GetItem in PlayInv.Items)
                    {
                        if (GetItem.GetComponent <SlaveProperties>() != null)
                        {
                            SlaveProperties CheckProp = GetItem.GetComponent <SlaveProperties>();
                            SlvLot          NewSlv    = new SlvLot();

                            NewSlv.Skin        = CheckProp.Skin;
                            NewSlv.Health      = CheckProp.Health;
                            NewSlv.FullHealth  = CheckProp.FullHealth;
                            NewSlv.Damage      = CheckProp.Damage;
                            NewSlv.Accuracy    = CheckProp.Accuracy;
                            NewSlv.Level       = CheckProp.Level;
                            NewSlv.Price       = CheckProp.Price;
                            NewSlv.St_Health   = CheckProp.Start_Fhp;
                            NewSlv.St_Damage   = CheckProp.Start_Dmg;
                            NewSlv.St_Accuracy = CheckProp.Start_Acc;
                            NewSlv.Shot_Units  = CheckProp.Shot_Units;
                            NewSlv.Heal_Units  = CheckProp.Heal_Units;
                            NewSlv.Rush_Units  = CheckProp.Rush_Units;

                            Store.Lot1.Add(NewSlv);
                        }
                        if (GetItem.GetComponent <WeaponProperties>() != null)
                        {
                            WeaponProperties CheckProp = GetItem.GetComponent <WeaponProperties>();
                            WpnLot           NewWpn    = new WpnLot();

                            NewWpn.Name      = CheckProp.name;
                            NewWpn.Skin      = CheckProp.Skin;
                            NewWpn.Price     = CheckProp.Price;
                            NewWpn.Damage    = CheckProp.Damage;
                            NewWpn.Condition = CheckProp.Condition;
                            NewWpn.Bullets   = CheckProp.Bullets;

                            Store.Lot2.Add(NewWpn);
                        }
                        if (GetItem.GetComponent <BulletsProperties>() != null)
                        {
                            BulletsProperties CheckProp = GetItem.GetComponent <BulletsProperties>();
                            BulLot            NewBul    = new BulLot();

                            NewBul.Skin  = CheckProp.Skin;
                            NewBul.Name  = CheckProp.Name;
                            NewBul.Count = CheckProp.Count;
                            NewBul.Price = CheckProp.Price;

                            Store.Lot3.Add(NewBul);
                        }
                        if (GetItem.GetComponent <OtherStuff>() != null)
                        {
                            OtherStuff CheckProp = GetItem.GetComponent <OtherStuff>();
                            StffLot    NewStff   = new StffLot();

                            NewStff.Skin   = CheckProp.Skin;
                            NewStff.Price  = CheckProp.Price;
                            NewStff.Liters = CheckProp.Liters;

                            Store.Lot4.Add(NewStff);
                        }
                    }
                }
            }

            string       NewStoreData = JsonUtility.ToJson(StoresInfo);
            StreamWriter WriteNewData = new StreamWriter(Application.persistentDataPath + "/StoresStack.json");
            WriteNewData.Write(NewStoreData);
            WriteNewData.Close();
        }
    }