Ejemplo n.º 1
0
    //================ Показываю экран покупки пуль ================
    public void BuyBulletsDisplay(BulletsProperties Bullets, WeaponProperties Weapon, int count, int totalprice)
    {
        Info.gameObject.active = true;
        Icon.GetComponent <WeaponProperties>().Skin = isActiveItem.GetComponent <WeaponProperties>().Skin;
        BulletsProperties GetBul = KeepBulletsItem.GetComponent <BulletsProperties>();

        Info.text      = GetBul.Name + " for\n" + Weapon.WeapName + "\nBullets: " + Weapon.Bullets + "\n\nCount: " + count + "\nPrice: " + Bullets.Price + "\n\nin total: " + totalprice;
        Minus.isActive = false;
        if (Bullets.Price <= PlayInv.Money)
        {
            Plus.isActive = true;
        }
        else
        {
            Plus.isActive = false;
        }
    }
Ejemplo 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();
        }
    }
Ejemplo n.º 3
0
    //======================================================= LOAD STORE ITEMS ===========================================================

    public void LoadStoreInfo(int StoreID)
    {
        if (File.Exists(Application.persistentDataPath + "/StoresStack.json"))
        {
            if (File.Exists(Application.persistentDataPath + "/PlayerData.json"))
            {
                string       GetPlayInfo   = File.ReadAllText(Application.persistentDataPath + "/PlayerData.json");
                PlayerSource GetPlaySource = JsonUtility.FromJson <PlayerSource>(GetPlayInfo);

                string     GetStoresInfo = File.ReadAllText(Application.persistentDataPath + "/StoresStack.json");
                StoreStack GetStore      = JsonUtility.FromJson <StoreStack>(GetStoresInfo);

                PlayInv.StoreID = GetPlaySource.CurrentStore;
                PlayInv.Money   = GetPlaySource.Money;

                int SlaveNum  = 0;
                int WeaponNum = 0;
                int BulletNum = 0;
                int StuffNum  = 0;
                foreach (StorePoint Store in GetStore.storePoint)
                {
                    if (Store.StoreID == PlayInv.StoreID)
                    {
                        PlayInv.TypeOfStore = Store.TypeOfStore;
                        foreach (SlvLot Slave in Store.Lot1)
                        {
                            GameObject Slv = Instantiate(Resources.Load("HeroPrefab")) as GameObject;
                            Slv.name = "Slv_" + SlaveNum;
                            SlaveProperties SlvProp = Slv.GetComponent <SlaveProperties>();
                            SlvProp.Skin       = Slave.Skin;
                            SlvProp.FullHealth = Slave.FullHealth;
                            SlvProp.Health     = Slave.Health;
                            SlvProp.Damage     = Slave.Damage;
                            SlvProp.Accuracy   = Slave.Accuracy;
                            SlvProp.Price      = Slave.Price;
                            SlvProp.Level      = Slave.Level;
                            SlvProp.Start_Fhp  = Slave.St_Health;
                            SlvProp.Start_Dmg  = Slave.St_Damage;
                            SlvProp.Start_Acc  = Slave.St_Accuracy;
                            SlvProp.Shot_Units = Slave.Shot_Units;
                            SlvProp.Heal_Units = Slave.Heal_Units;
                            SlvProp.Rush_Units = Slave.Rush_Units;
                            PlayInv.Items.Add(Slv);
                            SlaveNum += 1;
                        }
                        foreach (WpnLot Weapon in Store.Lot2)
                        {
                            GameObject Wpn = Instantiate(Resources.Load("WeaponDoll")) as GameObject;
                            Wpn.name = "Wpn_" + WeaponNum;
                            WeaponProperties WpnProp = Wpn.GetComponent <WeaponProperties>();
                            WpnProp.WeapName  = Weapon.Name;
                            WpnProp.Skin      = Weapon.Skin;
                            WpnProp.Price     = Weapon.Price;
                            WpnProp.Damage    = Weapon.Damage;
                            WpnProp.Condition = Weapon.Condition;
                            WpnProp.Bullets   = Weapon.Bullets;
                            PlayInv.Items.Add(Wpn);
                            WeaponNum += 1;
                        }
                        foreach (BulLot Bullets in Store.Lot3)
                        {
                            GameObject Bul = Instantiate(Resources.Load("BulletsDoll")) as GameObject;
                            Bul.name = "Bul_" + BulletNum;
                            BulletsProperties BulProp = Bul.GetComponent <BulletsProperties>();
                            BulProp.Name  = Bullets.Name;
                            BulProp.Skin  = Bullets.Skin;
                            BulProp.Count = Bullets.Count;
                            BulProp.Price = Bullets.Price;
                            PlayInv.Items.Add(Bul);
                            BulletNum += 1;
                        }
                        foreach (StffLot Stuff in Store.Lot4)
                        {
                            GameObject Stf = Instantiate(Resources.Load("OtherStuff")) as GameObject;
                            Stf.name = "Stf_" + StuffNum;
                            OtherStuff StfProp = Stf.GetComponent <OtherStuff>();
                            StfProp.Skin   = Stuff.Skin;
                            StfProp.Price  = Stuff.Price;
                            StfProp.Liters = Stuff.Liters;
                            PlayInv.Items.Add(Stf);
                            StuffNum += 1;
                        }
                    }
                }
            }
        }
    }