Пример #1
0
    public void StuffRandomize(int Number)
    {
        StffLot newItem = new StffLot();

        if (Number == 0)
        {
            newItem.Skin   = 2;
            newItem.Price  = 100;
            newItem.Liters = 100;
        }
        else
        {
            newItem.Skin = Random.Range(1, 4);
            if (newItem.Skin == 1)
            {
                newItem.Price = 200;
            }
            if (newItem.Skin == 2)
            {
                newItem.Price  = 100;
                newItem.Liters = 100;
            }
            if (newItem.Skin == 3)
            {
                newItem.Price = 150;
            }
        }
        Lot4.Add(newItem);
    }
Пример #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();
        }
    }