Exemplo n.º 1
0
    //=========================== Сохранение карты и ресурсов игрока =============================
    void SaveMapAndPlayerData()
    {
        if (File.Exists(Application.persistentDataPath + "/PlayerData.json"))
        {
            if (Player.GetComponent <PlayerChip>().TouchObject != null)
            {
                if (Player.GetComponent <PlayerChip>().TouchObject.gameObject.layer == 16)
                {
                    GameObject Store = Player.GetComponent <PlayerChip>().TouchObject.gameObject;
                    PlayInv.StoreID     = Store.GetComponent <StoreChip>().StoreID;
                    PlayInv.TypeOfStore = Store.GetComponent <StoreChip>().TypeOfStore;
                }
            }
            Loader.SaveAll();
        }

        if (File.Exists(Application.persistentDataPath + "/MapData.json"))
        {
            string MapData = File.ReadAllText(Application.persistentDataPath + "/MapData.json");

            MapData GetMapData = new MapData();
            GetMapData = JsonUtility.FromJson <MapData>(MapData);

            GetMapData.GenerateIndexes.PlayerCoords = Player.transform.localPosition;
            for (int t = 0; t < MapContainer.transform.childCount; t++)
            {
                GameObject GetMapIssue = MapContainer.transform.GetChild(t).gameObject;
                if (GetMapIssue.GetComponent <MapTile>() != null)
                {
                    GetMapData.Tiles[t].Skin = GetMapIssue.GetComponent <MapTile>().Skin;
                    for (int a = 0; a < GetMapIssue.GetComponent <MapTile>().SmokeOfWar.Length; a++)
                    {
                        if (GetMapIssue.GetComponent <MapTile>().SmokeOfWar[a].gameObject.active == false)
                        {
                            GetMapData.Tiles[t].Smokes[a] = false;
                        }
                        else
                        {
                            GetMapData.Tiles[t].Smokes[a] = true;
                        }
                    }
                }
            }

            string       NewMapData       = JsonUtility.ToJson(GetMapData);
            StreamWriter UploadNewMapData = new StreamWriter(Application.persistentDataPath + "/MapData.json");
            UploadNewMapData.Write(NewMapData);
            UploadNewMapData.Close();
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        //================================ Начало гринда =====================================
        if (LetsStart == true)
        {
            if (YourPass == true && BattleIsOver == false)
            {
                //elapsed += Time.deltaTime;
                //if (elapsed >= 1f) {
                //    TimeCounter -= 1;
                //    SecondsSound.Play();
                //    Debug.Log(Timer.transform.GetChild(TimeCounter).gameObject.name);
                //    Timer.transform.GetChild(TimeCounter).gameObject.active = false;
                //    elapsed = 0;
                //}

                //if (TimeCounter <= 0) {
                //    Nullify_Timer();
                //    EnemyPass();
                //    YourPass = false;
                //}

                if (Input.GetMouseButtonDown(0))
                {
                    RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                    if (hit.collider.gameObject.layer == SlavesLayer)
                    {
                        if (EnemyCurrent != null)
                        {
                            isActiveEnemy.isActive = false;
                            isActiveEnemy          = null;
                            EnemyCurrent           = null;
                        }
                        if (isActiveSlave != null)
                        {
                            if (isActiveSlave == hit.collider.gameObject.GetComponent <SlaveProperties>())
                            {
                                isActiveSlave.isActive = false;
                                SlaveCurrent           = null;
                                isActiveSlave          = null;
                            }
                            else
                            {
                                isActiveSlave.isActive = false;
                                isActiveSlave          = hit.collider.gameObject.GetComponent <SlaveProperties>();
                                SlaveCurrent           = hit.collider.gameObject;
                                isActiveSlave.isActive = true;
                            }
                        }
                        else
                        {
                            isActiveSlave          = hit.collider.gameObject.GetComponent <SlaveProperties>();
                            SlaveCurrent           = hit.collider.gameObject;
                            isActiveSlave.isActive = true;
                        }
                    }
                    if (hit.collider.gameObject.layer == ItemLayer)
                    {
                        if (hit.collider.gameObject.layer == ItemLayer)
                        {
                            if (isActiveStuff != null)
                            {
                                if (isActiveStuff.GetComponent <OtherStuff>() != null)
                                {
                                    isActiveStuff.isActive = false;
                                    SlaveCurrent           = null;
                                    isActiveStuff          = null;
                                }
                            }
                        }
                        if (hit.collider.gameObject.GetComponent <OtherStuff>() != null)
                        {
                            isActiveStuff          = hit.collider.gameObject.GetComponent <OtherStuff>();
                            StuffCurrent           = hit.collider.gameObject;
                            isActiveStuff.isActive = true;
                            if (isActiveSlave.Health != isActiveSlave.FullHealth)
                            {
                                if (isActiveStuff.Skin == 1)
                                {
                                    if (TimeCounter >= 3)
                                    {
                                        Heal_Timer_Minus();
                                        Heal.Play();
                                        isActiveSlave.Health = isActiveSlave.FullHealth;
                                        Destroy(StuffCurrent);
                                    }
                                }
                            }
                        }
                    }
                    if (hit.collider.gameObject.layer == EnemyLayer)
                    {
                        if (SlaveCurrent != null && isActiveSlave != null)
                        {
                            isActiveEnemy = hit.collider.gameObject.GetComponent <EnemyProperties>();
                            EnemyCurrent  = hit.collider.gameObject;
                            if (TimeCounter >= 5)
                            {
                                if (isActiveSlave.WeaponXRef != null)
                                {
                                    WeaponProperties SlvWeapon = isActiveSlave.WeaponXRef.gameObject.GetComponent <WeaponProperties>();
                                    if (SlvWeapon.Bullets != 0)
                                    {
                                        if (isActiveSlave != null)
                                        {
                                            Wait_A_Second          = true;
                                            isActiveSlave.isActive = false;
                                            if (Wait_A_Second == true)
                                            {
                                                isActiveSlave.OnFire();
                                                Wait_A_Second       = false;
                                                Final_Power_of_Shot = (int)isActiveSlave.PowerOfShot + Random.Range(-30, 30);
                                                SlvWeapon.Bullets--;
                                            }
                                            Shot_Timer_Minus();
                                        }
                                    }
                                    else
                                    {
                                        Misfire.Play();
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (isActiveEnemy != null)
                            {
                                if (EnemyCurrent == hit.collider.gameObject)
                                {
                                    isActiveEnemy.isActive = false;
                                    isActiveEnemy          = null;
                                    EnemyCurrent           = null;
                                }
                                else
                                {
                                    isActiveEnemy.isActive = false;
                                    isActiveEnemy          = null;
                                    EnemyCurrent           = null;
                                    isActiveEnemy          = hit.collider.gameObject.GetComponent <EnemyProperties>();
                                    EnemyCurrent           = hit.collider.gameObject;
                                    isActiveEnemy.isActive = true;
                                }
                            }
                            else
                            {
                                isActiveEnemy          = hit.collider.gameObject.GetComponent <EnemyProperties>();
                                EnemyCurrent           = hit.collider.gameObject;
                                isActiveEnemy.isActive = true;
                            }
                        }
                    }
                }


                //============================================ Ход врага ===============================================
            }
            else if (YourPass == false && BattleIsOver == false)
            {
                //if (TimeCounter <= 2) {

                //}
                if (Wait_A_Second == false)
                {
                    elapsed += Time.deltaTime;

                    if (EnemyCurrent != null)
                    {
                        isActiveEnemy.isActive = false;
                        isActiveEnemy          = null;
                        EnemyCurrent           = null;
                    }
                    if (SlaveCurrent != null)
                    {
                        isActiveSlave = null;
                        SlaveCurrent  = null;
                    }

                    if (elapsed >= 1f)
                    {
                        SecondsSound.Play();

                        Wait_A_Second = true;

                        int randEnm = Random.Range(0, Enemies.Count);
                        EnemyCurrent           = Enemies[randEnm].gameObject;
                        isActiveEnemy          = EnemyCurrent.GetComponent <EnemyProperties>();
                        isActiveEnemy.isActive = true;



                        //int rand = Random.Range(0, 2);
                        //if (rand == 0) {
                        //    if (TimeCounter >= 3) {

                        //            isActiveEnemy.isActive = false;
                        //            isActiveEnemy = null;
                        //            EnemyCurrent = null;
                        //            Wait_A_Second = false;
                        //        }
                        //    } else {
                        //        TimeCounter = 2;
                        //    }
                        //} else if (rand == 1) {
                        //}
                        if (TimeCounter >= 5)
                        {
                            int randSlv = Random.Range(0, Slaves.Count);
                            SlaveCurrent  = Slaves[randSlv].gameObject;
                            isActiveSlave = SlaveCurrent.GetComponent <SlaveProperties>();
                            isActiveEnemy.OnFire();
                            Final_Power_of_Shot = isActiveEnemy.PowerOfShot + Random.Range(-30, 30);
                            Shot_Timer_Minus();
                        }
                        else if (TimeCounter >= 3)
                        {
                            if (isActiveEnemy.Health != isActiveEnemy.FullHealth)
                            {
                                isActiveEnemy.Health = isActiveEnemy.FullHealth;
                                Heal_Timer_Minus();
                                Heal.Play();
                                Wait_A_Second = false;
                            }
                        }
                        else if (TimeCounter <= 2)
                        {
                            PlayerPass();
                            YourPass = true;
                            Nullify_Timer();
                        }
                        elapsed = 0;
                    }
                }

                if (EnemyCurrent != null)
                {
                    if (isActiveEnemy.ShellContainer != null)
                    {
                        if (SlaveCurrent != null)
                        {
                            isActiveEnemy.ShellContainer.gameObject.GetComponent <BulletShell>().Target = SlaveCurrent.gameObject;
                            if (isActiveEnemy.ShellContainer.GetComponent <BulletShell>().Gotcha == true)
                            {
                                ActivateShakes();
                                isActiveSlave.Health -= (int)isActiveEnemy.PowerOfShot;
                                if (isActiveSlave.Health <= 0)
                                {
                                    isActiveSlave.GetComponent <Animator>().SetBool("Dead", true);
                                    int plc = 0;
                                    foreach (GameObject slv in PlayInv.SlavePlace)
                                    {
                                        if (slv != null)
                                        {
                                            if (slv == SlaveCurrent)
                                            {
                                                PlayInv.SlavePlace[plc] = null;
                                            }
                                        }
                                        plc++;
                                    }
                                    Slaves.Remove(SlaveCurrent);
                                    SlaveCurrent.GetComponent <Collider2D>().enabled = false;
                                    SlaveCurrent.transform.SetParent(Trash.transform);
                                }
                                else
                                {
                                    isActiveSlave.GotDamage();
                                }

                                GameObject Dmg = Instantiate(Resources.Load("DmgNum")) as GameObject;
                                Dmg.transform.position = SlaveCurrent.transform.position + new Vector3(0, 0, -0.5f);
                                Dmg.transform.GetChild(0).gameObject.GetComponent <TextMesh>().text = "-" + Final_Power_of_Shot.ToString();

                                GameObject Sheel = isActiveEnemy.ShellContainer.gameObject;
                                Destroy(Sheel);
                                //isActiveSlave.isActive = false;
                                //isActiveEnemy.isActive = false;
                                //isActiveSlave = null;
                                //SlaveCurrent = null;
                                //isActiveEnemy = null;
                                //EnemyCurrent = null;

                                if (Slaves.Count == 0)
                                {
                                    if (Slaves.Count == 0)
                                    {
                                        Info_On_End_Battle(false);
                                    }
                                    if (Enemies.Count == 0)
                                    {
                                        Info_On_End_Battle(true);
                                    }
                                    BattleIsOver = true;
                                    Nullify_Timer();
                                    TimeCounter = 0;
                                }

                                Wait_A_Second = false;
                            }
                        }
                    }
                }
            }

            //======================== Если Пуля Раба достигла Врага ===========================
            if (isActiveSlave != null)
            {
                if (isActiveSlave.ShellContainer != null)
                {
                    if (EnemyCurrent != null)
                    {
                        isActiveSlave.ShellContainer.gameObject.GetComponent <BulletShell>().Target = EnemyCurrent.gameObject;
                        if (isActiveSlave.ShellContainer.GetComponent <BulletShell>().Gotcha == true)
                        {
                            ActivateShakes();
                            GameObject Sheel = isActiveSlave.ShellContainer.gameObject;
                            Destroy(Sheel);
                            isActiveEnemy.Health -= (int)isActiveSlave.PowerOfShot;
                            if (isActiveEnemy.Health <= 0)
                            {
                                isActiveSlave.Battles += isActiveEnemy.FullHealth;
                                isActiveSlave.Slaves_Level_Grade();
                                isActiveEnemy.GetComponent <Animator>().SetBool("Dead", true);
                                Enemies.Remove(EnemyCurrent);
                                EnemyCurrent.transform.SetParent(Trash.transform);
                                EnemyCurrent.GetComponent <Collider2D>().enabled = false;
                            }
                            else
                            {
                                isActiveSlave.Battles += (int)isActiveSlave.PowerOfShot;
                                isActiveSlave.Slaves_Level_Grade();
                                isActiveEnemy.Damaged();
                            }

                            GameObject Dmg = Instantiate(Resources.Load("DmgNum")) as GameObject;
                            Dmg.transform.position = EnemyCurrent.transform.position + new Vector3(0, 0, -0.5f);
                            Dmg.transform.GetChild(0).gameObject.GetComponent <TextMesh>().text = "-" + Final_Power_of_Shot.ToString();

                            isActiveSlave.isActive = false;
                            isActiveEnemy.isActive = false;
                            isActiveSlave          = null;
                            SlaveCurrent           = null;
                            isActiveEnemy          = null;
                            EnemyCurrent           = null;

                            if (Enemies.Count == 0)
                            {
                                if (Slaves.Count == 0)
                                {
                                    Info_On_End_Battle(false);
                                }
                                if (Enemies.Count == 0)
                                {
                                    Info_On_End_Battle(true);
                                }
                                Nullify_Timer();
                                BattleIsOver = true;
                                TimeCounter  = 0;
                            }
                        }
                    }
                }
            }

            //================== Нажать следующий ход =================
            if (SkipPass.gameObject.active == true)
            {
                if (SkipPass.isPressed == true)
                {
                    EnemyPass();
                    Nullify_Timer();
                    Wait_A_Second = false;
                    YourPass      = false;
                }
            }

            //=============== Битва окончена ================

            if (BattleIsOver == true)
            {
                elapsed += 1;
                if (elapsed >= 20f)
                {
                    TimeCounter++;

                    if (TimeCounter == 0)
                    {
                        PickMonitor.Play();
                        InfoText.active = true;
                    }
                    if (TimeCounter == 1)
                    {
                        InfoText.active = false;
                    }
                    if (TimeCounter == 2)
                    {
                        PickMonitor.Play();
                        InfoText.active = true;
                    }
                    if (TimeCounter == 3)
                    {
                        InfoText.active = false;
                    }
                    if (TimeCounter == 4)
                    {
                        PickMonitor.Play();
                        InfoText.active = true;
                    }
                    if (TimeCounter == 5)
                    {
                        InfoText.active = false;
                    }
                    if (TimeCounter == 6)
                    {
                        PickMonitor.Play();
                        InfoText.active = true;
                        Timer.active    = false;
                        int rename = 0;
                        foreach (Transform Stf in LOOT.transform)
                        {
                            Rename_Loot(Stf.gameObject, rename);
                            rename++;
                        }
                        Rotor.GetComponent <Animator>().SetBool("Activated", true);
                        FinalPanel.GetComponent <Animator>().SetBool("Activated", true);
                        FinalPanel.GetComponent <AudioSource>().Play();
                        TimeCounter++;
                    }
                    elapsed = 0;
                }
                //=============================== Забрать Лут ==================================

                if (Input.GetMouseButtonDown(0))
                {
                    RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                    if (hit.collider.gameObject.layer == ItemLayer)
                    {
                        if (hit.collider.gameObject.GetComponent <WeaponProperties>() != null)
                        {
                            WeaponProperties wpn = hit.collider.gameObject.GetComponent <WeaponProperties>();
                            if (wpn.isActive == false)
                            {
                                wpn.isActive = true;
                            }
                            else
                            {
                                wpn.isActive = false;
                            }
                            PickMonitor.Play();
                        }
                        if (hit.collider.gameObject.GetComponent <OtherStuff>() != null)
                        {
                            OtherStuff stf = hit.collider.gameObject.GetComponent <OtherStuff>();
                            if (stf.isActive == false)
                            {
                                stf.isActive = true;
                            }
                            else
                            {
                                stf.isActive = false;
                            }
                            PickMonitor.Play();
                        }
                    }
                }
                if (TakeLootButton.GetComponent <ButtonSample>().isPressed == true)
                {
                    foreach (GameObject loot in Loots)
                    {
                        if (loot != null)
                        {
                            if (loot.GetComponent <OtherStuff>() != null)
                            {
                                OtherStuff prop = loot.GetComponent <OtherStuff>();
                                if (prop.isActive == true)
                                {
                                    if (prop.Skin != 4)
                                    {
                                        int plcnum = 0;
                                        foreach (GameObject plc in PlayInv.Package)
                                        {
                                            if (plc == null)
                                            {
                                                PlayInv.Package[plcnum] = loot;
                                                if (prop.Skin == 1)
                                                {
                                                    TakeMedicine.Play();
                                                }
                                                if (prop.Skin == 2)
                                                {
                                                    TakeWater.Play();
                                                }
                                                if (prop.Skin == 3)
                                                {
                                                    TakeBuff.Play();
                                                }
                                                Names[int.Parse(loot.name)].gameObject.active = false;
                                                loot.transform.SetParent(Loader.ItemsSource.transform);
                                                loot.transform.localPosition = new Vector3(0, 0, 0);
                                                prop.isActive   = false;
                                                OverLoad.active = false;
                                                break;
                                            }
                                            else
                                            {
                                                OverLoad.active = true;
                                            }
                                            plcnum++;
                                        }
                                    }
                                    else
                                    {
                                        Names[int.Parse(loot.name)].gameObject.active = false;
                                        PlayInv.Money += prop.Price;
                                        TakeMoney.Play();
                                        Destroy(loot);
                                    }
                                }
                            }
                            else if (loot.GetComponent <WeaponProperties>() != null)
                            {
                                WeaponProperties prop = loot.GetComponent <WeaponProperties>();
                                if (prop.isActive == true)
                                {
                                    int plcnum = 0;
                                    foreach (GameObject plc in PlayInv.Package)
                                    {
                                        if (plc == null)
                                        {
                                            PlayInv.Package[plcnum] = loot;
                                            TakeWeapon.Play();
                                            Names[int.Parse(loot.name)].gameObject.active = false;
                                            loot.transform.SetParent(Loader.ItemsSource.transform);
                                            loot.transform.localPosition = new Vector3(0, 0, 0);
                                            prop.isActive   = false;
                                            OverLoad.active = false;
                                            break;
                                        }
                                        else
                                        {
                                            OverLoad.active = true;
                                        }
                                        plcnum++;
                                    }
                                }
                            }
                        }
                    }
                }

                if (BackToMap.GetComponent <ButtonSample>().isPressed == true)
                {
                    Loader.SaveAll();
                    //Debug.Log("Already");
                    Loader.Save_Enemy_Data(Enm_Data.NumberOfArea, Enm_Data.Count);
                    TakeLootButton.active = false;
                    BackToMap.active      = false;
                    OverLoad.active       = false;
                    LOOT.active           = false;
                    foreach (TextMesh name in Names)
                    {
                        name.gameObject.active = false;
                    }
                    TuningTable.GetComponent <Animator>().SetBool("Activation", true);
                    BackToMap.GetComponent <ButtonSample>().isPressed = false;
                }
            }


            //================================= Если нажать Game Over ===================================

            if (GameOverButton.GetComponent <ButtonSample>().isPressed == true)
            {
                if (File.Exists(Application.persistentDataPath + "/PlayerData.json"))
                {
                    File.Delete(Application.persistentDataPath + "/PlayerData.json");
                }
                if (File.Exists(Application.persistentDataPath + "/MapData.json"))
                {
                    File.Delete(Application.persistentDataPath + "/MapData.json");
                }
                if (File.Exists(Application.persistentDataPath + "/BanditTroop.json"))
                {
                    File.Delete(Application.persistentDataPath + "/BanditTroop.json");
                }
                if (File.Exists(Application.persistentDataPath + "/StoresStack.json"))
                {
                    File.Delete(Application.persistentDataPath + "/StoresStack.json");
                }
                SceneManager.LoadScene(0);
            }
        }
    }
Exemplo n.º 3
0
    public void Update()
    {
        Money.text = PlayInv.Money.ToString();

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            //============================================================== SELECT SLAVE ================================================================

            if (hit.collider.gameObject.layer == SlaveLayer)
            {
                //================ Если кликнул на выделенного раба ================
                if (isActiveSlave == hit.collider.gameObject)
                {
                    isActiveSlave.GetComponent <SlaveProperties>().isActive = false;
                    foreach (Transform Field in SlaveFields.transform)
                    {
                        Field.GetComponent <Fields>().isActive = false;
                    }
                    foreach (Transform Field in ItemFields.transform)
                    {
                        Field.GetComponent <Fields>().isActive = false;
                    }
                    isActiveSlave = null;
                    if (BuyButton != null)
                    {
                        BuyButton.isActive = false;
                    }
                    Greeting1();
                }
                else
                {
                    //================ Если новое выделение ================
                    if (isActiveSlave != null)
                    {
                        isActiveSlave.GetComponent <SlaveProperties>().isActive = false;
                        isActiveSlave = null;
                    }
                    isActiveSlave = hit.collider.gameObject;
                    SlaveProperties GetProp = isActiveSlave.GetComponent <SlaveProperties>();
                    GetProp.isActive = true;

                    foreach (Transform Field in SlaveFields.transform)
                    {
                        Field.GetComponent <Fields>().isActive = true;
                    }

                    ShowSlaveInfo();

                    if (GetProp.Price <= PlayInv.Money)
                    {
                        if (GetProp.Bought == false)
                        {
                            foreach (GameObject slvplace in PlayInv.SlavePlace)
                            {
                                if (slvplace == null)
                                {
                                    if (BuyButton != null)
                                    {
                                        BuyButton.isActive = true;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    //============================================================== DROP ITEM ================================================================
                    if (isActiveItem != null)
                    {
                        GameObject Pack = GetProp.InventoryPack.gameObject;

                        foreach (Transform Place in Pack.transform)
                        {
                            if (Place.transform.childCount == 0)
                            {
                                //==================== если опускаемый предмет пушка ======================
                                if (isActiveItem.GetComponent <WeaponProperties>() != null)
                                {
                                    if (isActiveSlave.GetComponent <SlaveProperties>().HaveGun == false)
                                    {
                                        WeaponProperties prop = isActiveItem.GetComponent <WeaponProperties>();
                                        isActiveItem.transform.SetParent(Place.transform);
                                        isActiveItem.transform.localPosition = new Vector3(0, 0, 0);
                                        prop.isActive      = false;
                                        prop.Bought        = true;
                                        GetProp.HaveGun    = true;
                                        GetProp.WeaponXRef = isActiveItem;
                                        PutWeapPlace.Play();
                                        int removePlace = 0;
                                        foreach (GameObject Item in PlayInv.Package)
                                        {
                                            if (Item == isActiveItem)
                                            {
                                                PlayInv.Package[removePlace] = null;
                                            }
                                            removePlace++;
                                        }
                                    }
                                    else
                                    {
                                        isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                                        isActiveItem = null;
                                        foreach (Transform Fields in ItemFields.transform)
                                        {
                                            Fields.GetComponent <Fields>().isActive = false;
                                        }
                                        break;
                                    }
                                }
                                //==================== другие опускаемые предметы ======================
                                if (isActiveItem.GetComponent <OtherStuff>() != null)
                                {
                                    OtherStuff prop = isActiveItem.GetComponent <OtherStuff>();
                                    isActiveItem.transform.SetParent(Place.transform);
                                    isActiveItem.transform.localPosition = new Vector3(0, 0, 0);
                                    prop.isActive = false;
                                    prop.Bought   = true;
                                    if (prop.Skin == 1)
                                    {
                                        PutMedicine.Play();
                                    }
                                    if (prop.Skin == 2)
                                    {
                                        PutWater.Play();
                                    }
                                    if (prop.Skin == 3)
                                    {
                                        PutBuff.Play();
                                    }
                                    int removePlace = 0;
                                    foreach (GameObject Item in PlayInv.Package)
                                    {
                                        if (Item == isActiveItem)
                                        {
                                            PlayInv.Package[removePlace] = null;
                                        }
                                        removePlace++;
                                    }
                                }
                                //================ Закрываем поля с предметами ================
                                foreach (Transform Field in ItemFields.transform)
                                {
                                    Field.GetComponent <Fields>().isActive = false;
                                }
                                isActiveItem = null;
                                break;
                            }
                        }
                    }
                    //===== Скрываю все предметы в слотах рюкзака =====
                    HideBag(isActiveSlave);
                }
            }

            //============================================================== SELECT ITEM ================================================================

            if (hit.collider.gameObject.layer == ItemLayer)
            {
                //==================== Снимаю выделение с раба ====================
                bool getbought = GetBought(hit.collider.gameObject);
                if (getbought == false)
                {
                    if (isActiveSlave != null)
                    {
                        isActiveSlave.GetComponent <SlaveProperties>().isActive = false;
                        isActiveSlave = null;
                    }
                }

                //==================== Если клинкнул на выделенный предмет ====================
                if (isActiveItem == hit.collider.gameObject)
                {
                    if (isActiveItem.GetComponent <WeaponProperties>() != null)
                    {
                        isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                        foreach (Transform Field in ItemFields.transform)
                        {
                            Field.GetComponent <Fields>().isActive = false;
                        }
                        if (isActiveItem.GetComponent <WeaponProperties>().Bought == true)
                        {
                            PickMonitor.Play();
                        }
                        else
                        {
                            TakeWeap.Play();
                        }
                        isActiveItem = null;
                        ShowYourItems();
                    }
                    else if (isActiveItem.GetComponent <OtherStuff>() != null)
                    {
                        isActiveItem.GetComponent <OtherStuff>().isActive = false;
                        foreach (Transform Field in ItemFields.transform)
                        {
                            Field.GetComponent <Fields>().isActive = false;
                        }
                        if (isActiveItem.GetComponent <OtherStuff>().Bought == true)
                        {
                            PickMonitor.Play();
                        }
                        isActiveItem = null;
                        ShowYourItems();
                    }
                    else if (isActiveItem.GetComponent <BulletsProperties>() != null)
                    {
                        isActiveItem.GetComponent <BulletsProperties>().isActive = false;
                        isActiveItem = null;
                        HideBulletsDisplay();
                        KeepBulletsItem = null;
                        BulletsEngine.Deselect();
                    }
                    if (BuyButton != null)
                    {
                        BuyButton.isActive = false;
                    }
                }
                else
                {
                    //==================== Если выделение на новом объекте ====================

                    if (isActiveItem != null)
                    {
                        if (isActiveItem.GetComponent <WeaponProperties>() != null)
                        {
                            isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                        }
                        if (isActiveItem.GetComponent <OtherStuff>() != null)
                        {
                            isActiveItem.GetComponent <OtherStuff>().isActive = false;
                        }
                        if (isActiveItem.GetComponent <BulletsProperties>() != null)
                        {
                            if (hit.collider.gameObject.GetComponent <BulletsProperties>() != null)
                            {
                                isActiveItem.GetComponent <BulletsProperties>().isActive = false;
                            }
                            else
                            {
                                KeepBulletsItem = isActiveItem;
                            }
                        }
                        if (BuyButton != null)
                        {
                            BuyButton.isActive = false;
                        }
                        isActiveItem = null;
                    }


                    isActiveItem = hit.collider.gameObject;
                    //TakeWeap.Play();
                    int  price  = 0;
                    bool bought = false;

                    if (isActiveItem.GetComponent <WeaponProperties>() != null)
                    {
                        isActiveItem.GetComponent <WeaponProperties>().isActive = true;
                        price  = isActiveItem.GetComponent <WeaponProperties>().Price;
                        bought = isActiveItem.GetComponent <WeaponProperties>().Bought;
                        if (isActiveItem.GetComponent <WeaponProperties>().Bought == true)
                        {
                            PickMonitor.Play();
                        }
                        if (KeepBulletsItem == null)
                        {
                            ShowWeaponInfo();
                        }
                        else if (KeepBulletsItem != null)
                        {
                            PickMonitor.Play();
                            BoughtItems.active = false;
                            BuyBulletsDisplay(KeepBulletsItem.GetComponent <BulletsProperties>(), isActiveItem.GetComponent <WeaponProperties>(), 0, 0);
                        }
                        if (GetTutor != null)
                        {
                            if (GetTutor.Steps == 41)
                            {
                                GetTutor.Steps  += 1;
                                GetTutor.enabled = false;
                                GetTutor.enabled = true;
                                GetTutor.PickMonitor.Play();
                            }
                        }
                    }
                    if (isActiveItem.GetComponent <OtherStuff>() != null)
                    {
                        isActiveItem.GetComponent <OtherStuff>().isActive = true;
                        price  = isActiveItem.GetComponent <OtherStuff>().Price;
                        bought = isActiveItem.GetComponent <OtherStuff>().Bought;
                        if (isActiveItem.GetComponent <OtherStuff>().Bought == true)
                        {
                            PickMonitor.Play();
                        }
                    }
                    if (isActiveItem.GetComponent <BulletsProperties>() != null)
                    {
                        isActiveItem.GetComponent <BulletsProperties>().isActive = true;
                        price = isActiveItem.GetComponent <BulletsProperties>().Price;
                        HideBulletsDisplay();
                        BulletsEngine.ShowMatchWeapons(isActiveItem);
                        if (KeepBulletsItem != null)
                        {
                            if (KeepBulletsItem == isActiveItem)
                            {
                                KeepBulletsItem.GetComponent <BulletsProperties>().isActive = false;
                                KeepBulletsItem = null;
                                isActiveItem    = null;
                                BulletsEngine.Deselect();
                            }
                            else
                            {
                                KeepBulletsItem.GetComponent <BulletsProperties>().isActive = false;
                                KeepBulletsItem = null;
                                BulletsEngine.ShowMatchWeapons(isActiveItem);
                            }
                        }
                        if (GetTutor != null)
                        {
                            if (GetTutor.Steps == 40)
                            {
                                GetTutor.Selected    = isActiveItem;
                                GetTutor.Steps      += 1;
                                GetTutor.Main.active = true;
                                //GetTutor.enabled = false;
                                //GetTutor.enabled = true;
                                GetTutor.PickMonitor.Play();
                            }
                        }
                        price          = PlayInv.Money + 1;
                        Count_of_Items = 0;
                    }
                    foreach (Transform Field in ItemFields.transform)
                    {
                        Field.GetComponent <Fields>().isActive = true;
                    }

                    //==================== Активирую кнопку Купить ====================
                    if (price <= PlayInv.Money)
                    {
                        if (bought == false)
                        {
                            foreach (GameObject slvplace in PlayInv.Package)
                            {
                                if (slvplace == null)
                                {
                                    if (BuyButton != null)
                                    {
                                        BuyButton.isActive = true;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            //============================================================== DROP ITEM TO FIELD ================================================================

            if (hit.collider.gameObject.layer == FieldLayer)
            {
                if (isActiveItem != null)
                {
                    if (hit.collider.gameObject.transform.parent.gameObject == ItemFields.gameObject)
                    {
                        //============== Проверяю куплен ли предмет ==============
                        bool Bought = GetBought(isActiveItem);
                        if (Bought == false)
                        {
                            GameObject FieldPlace = hit.collider.gameObject;
                            isActiveItem.transform.position = FieldPlace.transform.position + new Vector3(0, 0, -0.1f);
                            int GetNum = 0;
                            foreach (GameObject item in PlayInv.Package)
                            {
                                if (item == isActiveItem)
                                {
                                    PlayInv.Package[GetNum] = null;
                                }
                                GetNum += 1;
                            }
                            //=================== Отключаю поля в инвентаре ===================
                            foreach (Transform Field in ItemFields.transform)
                            {
                                Field.GetComponent <Fields>().isActive = false;
                            }
                            //==================== Кладу предмет в головном файле ====================
                            PlayInv.Package[FieldPlace.transform.GetSiblingIndex()] = isActiveItem;

                            if (isActiveItem.GetComponent <WeaponProperties>() != null)
                            {
                                PutWeapPlace.Play();
                                isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                                isActiveItem = null;
                            }
                            else if (isActiveItem.GetComponent <OtherStuff>() != null)
                            {
                                if (isActiveItem.GetComponent <OtherStuff>().Skin == 1)
                                {
                                    PutMedicine.Play();
                                }
                                if (isActiveItem.GetComponent <OtherStuff>().Skin == 2)
                                {
                                    PutWater.Play();
                                }
                                if (isActiveItem.GetComponent <OtherStuff>().Skin == 3)
                                {
                                    PutBuff.Play();
                                }
                                isActiveItem.GetComponent <OtherStuff>().isActive = false;
                                isActiveItem = null;
                            }
                        }
                        else
                        {
                            //============== Если премдет был куплен ==============
                            isActiveItem.transform.SetParent(ItemsSource.transform);
                            if (isActiveItem.GetComponent <WeaponProperties>() != null)
                            {
                                isActiveItem.GetComponent <WeaponProperties>().Bought   = false;
                                isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                                if (isActiveSlave != null)
                                {
                                    isActiveSlave.GetComponent <SlaveProperties>().HaveGun    = false;
                                    isActiveSlave.GetComponent <SlaveProperties>().WeaponXRef = null;
                                }
                                PutWeapPlace.Play();
                            }
                            else if (isActiveItem.GetComponent <OtherStuff>() != null)
                            {
                                isActiveItem.GetComponent <OtherStuff>().Bought   = false;
                                isActiveItem.GetComponent <OtherStuff>().isActive = false;
                                OtherStuff getstf = isActiveItem.GetComponent <OtherStuff>();
                                if (getstf.Skin == 1)
                                {
                                    PutMedicine.Play();
                                }
                                if (getstf.Skin == 2)
                                {
                                    PutWater.Play();
                                }
                                if (getstf.Skin == 3)
                                {
                                    PutBuff.Play();
                                }
                            }
                            GameObject FieldPlace = hit.collider.gameObject;
                            isActiveItem.transform.position = FieldPlace.transform.position + new Vector3(0, 0, -0.1f);
                            foreach (Transform Field in ItemFields.transform)
                            {
                                Field.GetComponent <Fields>().isActive = false;
                            }
                            foreach (Transform Field in SlaveFields.transform)
                            {
                                Field.GetComponent <Fields>().isActive = false;
                            }
                            if (isActiveSlave != null)
                            {
                                isActiveSlave.GetComponent <SlaveProperties>().isActive = false;
                                isActiveSlave = null;
                            }
                            PlayInv.Package[FieldPlace.transform.GetSiblingIndex()] = isActiveItem;
                            isActiveItem = null;
                            if (GetTutor != null)
                            {
                                if (GetTutor.Steps == 29)
                                {
                                    GetTutor.Steps      += 1;
                                    GetTutor.Main.active = false;
                                    GetTutor.Main.active = true;
                                    PickMonitor.Play();
                                }
                            }
                        }
                    }
                }
            }
        }

        //============================================================== DROP SLAVE TO FIELD ================================================================

        if (Input.GetMouseButtonUp(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (isActiveSlave != null)
            {
                ShowBag(isActiveSlave);
            }

            if (hit.collider.gameObject.layer == FieldLayer)
            {
                if (isActiveSlave != null)
                {
                    if (hit.collider.gameObject.transform.parent.gameObject == SlaveFields.gameObject)
                    {
                        GameObject FieldPlace = hit.collider.gameObject;
                        isActiveSlave.transform.position = FieldPlace.transform.position + new Vector3(0, 0, -0.1f);
                        int GetNum = 0;
                        foreach (GameObject Slv in PlayInv.SlavePlace)
                        {
                            if (Slv == isActiveSlave)
                            {
                                PlayInv.SlavePlace[GetNum] = null;
                            }
                            GetNum += 1;
                        }
                        foreach (Transform Field in SlaveFields.transform)
                        {
                            Field.GetComponent <Fields>().isActive = false;
                        }
                        PlayInv.SlavePlace[FieldPlace.transform.GetSiblingIndex()] = isActiveSlave;
                        isActiveSlave.GetComponent <SlaveProperties>().isActive    = false;

                        isActiveSlave = null;
                        SetPers.Play();
                    }
                }
                if (isActiveItem != null)
                {
                    if (isActiveItem.GetComponent <WeaponProperties>() != null)
                    {
                        isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                    }
                    else if (isActiveItem.GetComponent <OtherStuff>() != null)
                    {
                        isActiveItem.GetComponent <OtherStuff>().isActive = false;
                    }
                    isActiveItem = null;
                    foreach (Transform Field in ItemFields.transform)
                    {
                        Field.GetComponent <Fields>().isActive = false;
                    }
                }
                if (GetTutor != null)
                {
                    if (GetTutor.Steps == 32)
                    {
                        GetTutor.Steps  += 1;
                        GetTutor.enabled = false;
                        GetTutor.enabled = true;
                        GetTutor.PickMonitor.Play();
                    }
                }
            }
        }

        //============================================================== PLUS/MINUS ================================================================

        if (Plus != null && Minus != null)
        {
            if (Plus.isPressed == true)
            {
                int price          = KeepBulletsItem.GetComponent <BulletsProperties>().Price;
                int Count_in_Store = KeepBulletsItem.GetComponent <BulletsProperties>().Count;
                Count_of_Items += 1;
                PlusAction(price, Count_of_Items, Count_in_Store);
                if (GetTutor != null)
                {
                    if (GetTutor.Steps == 42)
                    {
                        GetTutor.Steps  += 1;
                        GetTutor.enabled = false;
                        GetTutor.enabled = true;
                    }
                }
            }

            if (Minus.isPressed == true)
            {
                int price          = KeepBulletsItem.GetComponent <BulletsProperties>().Price;
                int Count_in_Store = KeepBulletsItem.GetComponent <BulletsProperties>().Count;
                Count_of_Items -= 1;
                PlusAction(price, Count_of_Items, Count_in_Store);
            }
        }

        //============================================================== CLICK BUY ================================================================
        if (BuyButton != null)
        {
            if (BuyButton.isPressed == true)
            {
                if (isActiveSlave != null)
                {
                    isActiveSlave.transform.SetParent(SlavesSource.transform);
                    int SetPlace = 0;
                    foreach (GameObject SlvPlace in PlayInv.SlavePlace)
                    {
                        if (SlvPlace == null)
                        {
                            PlayInv.SlavePlace[SetPlace] = isActiveSlave;
                            break;
                        }
                        SetPlace += 1;
                    }
                    PlayInv.Money -= isActiveSlave.GetComponent <SlaveProperties>().Price;
                    isActiveSlave.GetComponent <SlaveProperties>().Bought = true;
                    isActiveSlave.transform.position = BoughtItems.transform.GetChild(isActiveSlave.transform.GetSiblingIndex()).transform.position;
                    BoughtItems.transform.GetChild(isActiveSlave.transform.GetSiblingIndex()).gameObject.active = false;
                    isActiveSlave.GetComponent <SlaveProperties>().isActive = false;
                    PlayInv.Items.Remove(isActiveSlave);
                    isActiveSlave      = null;
                    BuyButton.isActive = false;
                    Greeting1();
                }
                if (isActiveItem != null)
                {
                    if (BulletsEngine == null)
                    {
                        isActiveItem.transform.SetParent(ItemsSource.transform);
                    }

                    int SetPlace = 0;
                    if (isActiveItem.GetComponent <WeaponProperties>() != null)
                    {
                        if (KeepBulletsItem == null)
                        {
                            foreach (GameObject ItemPlace in PlayInv.Package)
                            {
                                if (ItemPlace == null)
                                {
                                    PlayInv.Package[SetPlace] = isActiveItem;
                                    PlayInv.Money            -= isActiveItem.GetComponent <WeaponProperties>().Price;
                                    isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                                    isActiveItem.GetComponent <WeaponProperties>().Bought   = true;
                                    isActiveItem.transform.position = BoughtItems.transform.GetChild(SetPlace).transform.position;
                                    BoughtItems.transform.GetChild(SetPlace).gameObject.active = false;
                                    PlayInv.Items.Remove(isActiveItem);
                                    break;
                                }
                                SetPlace++;
                            }
                        }
                        else
                        {
                            PlayInv.Money -= TotalPrice;
                            Debug.Log(TotalPrice);
                            isActiveItem.GetComponent <WeaponProperties>().Bullets += Count_of_Items;
                            WeaponProperties WeapRef = isActiveItem.GetComponent <WeaponProperties>().WeaponXRef.gameObject.GetComponent <WeaponProperties>();
                            WeapRef.Bullets += Count_of_Items;
                            KeepBulletsItem.GetComponent <BulletsProperties>().Count -= Count_of_Items;
                            if (KeepBulletsItem.GetComponent <BulletsProperties>().Count <= 0)
                            {
                                PlayInv.Items.Remove(KeepBulletsItem);
                                Destroy(KeepBulletsItem);
                            }
                            else
                            {
                                KeepBulletsItem.GetComponent <BulletsProperties>().isActive = false;
                            }
                            BulletsEngine.Deselect();
                            HideBulletsDisplay();
                        }
                    }
                    else if (isActiveItem.GetComponent <OtherStuff>() != null)
                    {
                        foreach (GameObject ItemPlace in PlayInv.Package)
                        {
                            if (ItemPlace == null)
                            {
                                PlayInv.Package[SetPlace] = isActiveItem;
                                PlayInv.Money            -= isActiveItem.GetComponent <OtherStuff>().Price;
                                isActiveItem.GetComponent <OtherStuff>().isActive = false;
                                isActiveItem.GetComponent <OtherStuff>().Bought   = true;
                                isActiveItem.transform.position = BoughtItems.transform.GetChild(SetPlace).transform.position;
                                BoughtItems.transform.GetChild(SetPlace).gameObject.active = false;
                                PlayInv.Items.Remove(isActiveItem);
                                break;
                            }
                            SetPlace++;
                        }
                    }
                    if (KeepBulletsItem != null)
                    {
                        KeepBulletsItem = null;
                    }
                    isActiveItem       = null;
                    BuyButton.isActive = false;
                    ShowYourItems();
                    if (GetTutor != null)
                    {
                        if (GetTutor.Steps == 24 || GetTutor.Steps == 43)
                        {
                            GetTutor.Steps  += 1;
                            GetTutor.enabled = false;
                            GetTutor.enabled = true;
                            GetTutor.PickMonitor.Play();
                        }
                    }
                }
            }
        }

        //============================================================== SWITCH PANELS ================================================================

        if (MenuSwitcher != null)
        {
            if (MenuSwitcher.isPressed == true)
            {
                if (isActiveSlave != null)
                {
                    isActiveSlave.GetComponent <SlaveProperties>().isActive = false;
                    isActiveSlave = null;
                }
                if (isActiveItem != null)
                {
                    if (isActiveItem.GetComponent <WeaponProperties>() != null)
                    {
                        isActiveItem.GetComponent <WeaponProperties>().isActive = false;
                    }
                    if (isActiveItem.GetComponent <OtherStuff>() != null)
                    {
                        isActiveItem.GetComponent <OtherStuff>().isActive = false;
                    }
                    if (isActiveItem.GetComponent <BulletsProperties>() != null)
                    {
                        isActiveItem.GetComponent <BulletsProperties>().isActive = false;
                    }
                    if (KeepBulletsItem != null)
                    {
                        KeepBulletsItem.GetComponent <BulletsProperties>().isActive = false;
                        KeepBulletsItem = null;
                    }
                    isActiveItem = null;
                }
                foreach (Transform Field in SlaveFields.transform)
                {
                    Field.GetComponent <Fields>().isActive = false;
                }
                foreach (Transform Field in ItemFields.transform)
                {
                    Field.GetComponent <Fields>().isActive = false;
                }
                if (BulletsEngine != null)
                {
                    BulletsEngine.Deselect();
                }
                BuyButton.isActive = false;
                Greeting1();
                if (GetTutor != null)
                {
                    if (GetTutor.Steps == 6 || GetTutor.Steps == 26)
                    {
                        GetTutor.Steps  += 1;
                        GetTutor.enabled = false;
                        GetTutor.enabled = true;
                        GetTutor.PickMonitor.Play();
                    }
                }
            }
        }
        else
        {
            INVENTORY.active = true;
        }

        if (GoToMap.isPressed == true)
        {
            if (GetTutor != null)
            {
                if (GetTutor.Steps == 15 || GetTutor.Steps == 33 || GetTutor.Steps == 44)
                {
                    GetTutor.Steps += 1;
                    GetTutor.PickMonitor.Play();
                }
            }
            Loader.SaveAll();
            Loader.SaveStoresInfo();
            SceneManager.LoadScene(5);
        }
    }