예제 #1
0
 void Nullify_Timer()
 {
     TimeCounter = 12;
     foreach (Transform sec in Timer.transform)
     {
         sec.gameObject.active = true;
     }
     if (isActiveEnemy != null)
     {
         isActiveEnemy.isActive = false;
     }
     if (isActiveSlave != null)
     {
         isActiveSlave.isActive = false;
     }
     if (isActiveStuff != null)
     {
         isActiveStuff.isActive = false;
     }
     isActiveSlave = null;
     isActiveEnemy = null;
     isActiveStuff = null;
     SlaveCurrent  = null;
     EnemyCurrent  = null;
     StuffCurrent  = null;
 }
예제 #2
0
 //========================== Choose only Weapon =============================
 public void FindWeapons(BulletsEngine Bullets)
 {
     foreach (GameObject slv in PlayInv.SlavePlace)
     {
         if (slv != null)
         {
             SlaveProperties prop = slv.GetComponent <SlaveProperties>();
             GameObject      Pack = prop.InventoryPack.gameObject;
             foreach (Transform Plc in Pack.transform)
             {
                 if (Plc.transform.childCount != 0)
                 {
                     GameObject Item = Plc.transform.GetChild(0).gameObject;
                     if (Item.GetComponent <WeaponProperties>() != null)
                     {
                         Bullets.Weapons.Add(Item);
                     }
                 }
             }
         }
     }
     foreach (GameObject Item in PlayInv.Package)
     {
         if (Item != null)
         {
             if (Item.GetComponent <WeaponProperties>() != null)
             {
                 Bullets.Weapons.Add(Item);
             }
         }
     }
 }
예제 #3
0
    public void ShowSlaveInfo()
    {
        SlaveProperties Slv = isActiveSlave.GetComponent <SlaveProperties>();

        if (Info != null)
        {
            Info.text = "health: " + Slv.Health + "       damage: " + Slv.Damage + "\naccuracy: " + Slv.Accuracy + "       price: " + Slv.Price;
        }
    }
예제 #4
0
    //================ Активирую предметы в инвентаре раба ================
    public void ShowBag(GameObject ActivePers)
    {
        SlaveProperties GetSlv = ActivePers.GetComponent <SlaveProperties>();
        GameObject      Bag    = GetSlv.InventoryPack.gameObject;

        foreach (Transform Place in Bag.transform)
        {
            if (Place.transform.childCount != 0)
            {
                Place.transform.GetChild(0).gameObject.active = true;
            }
        }
    }
예제 #5
0
    void Slv_Show()
    {
        SlaveProperties prop           = isActiveSlave.GetComponent <SlaveProperties>();
        int             health_percent = (int)(100 * ((float)prop.Health / (float)prop.FullHealth));

        Description.text = "life: " + health_percent + "%" + "\nfull hp: " + prop.FullHealth + "\nexp: " + prop.Battles + "\nlevel: " + prop.Level +
                           "\ndamage: " + prop.Damage + "\naccuracy: " + prop.Accuracy;
        Heal_Button.active = false;
        //if (Repair_Button != null) {
        //    Repair_Button.active = false;
        //}
        //if (Sell_Button != null) {
        //    Sell_Button.active = false;
        //}
    }
예제 #6
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);
            }
        }
    }
예제 #7
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);
        }
    }
예제 #8
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();
        }
    }
예제 #9
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;
                        }
                    }
                }
            }
        }
    }
예제 #10
0
    //======================================================= SAVE INVENTORY ===========================================================

    public void SaveAll()
    {
        PlayerSource newInventory = new PlayerSource();

        newInventory.Money            = PlayInv.Money;
        newInventory.CurrentStore     = PlayInv.StoreID;
        newInventory.If_Tutorial      = PlayInv.If_Tutorial;
        newInventory.Step_Of_Tutorial = Tutor.Steps;

        foreach (GameObject Slave in PlayInv.SlavePlace)
        {
            SlaveDoll newSlave = new SlaveDoll();
            if (Slave != null)
            {
                SlaveProperties GetSlv = Slave.GetComponent <SlaveProperties>();
                newSlave.StatusEmpty = false;
                newSlave.Number      = GetSlv.Number;
                newSlave.Health      = GetSlv.Health;
                newSlave.FullHealth  = GetSlv.FullHealth;
                newSlave.Damage      = GetSlv.Damage;
                newSlave.Accuracy    = GetSlv.Accuracy;
                newSlave.Battles     = GetSlv.Battles;
                newSlave.Level       = GetSlv.Level;
                newSlave.Skin        = GetSlv.Skin;
                newSlave.Price       = GetSlv.Price;
                newSlave.Efficiency  = GetSlv.Efficiency;
                newSlave.WeaponSkin  = GetSlv.WeaponSkin;
                newSlave.HaveGun     = GetSlv.HaveGun;
                newSlave.FullPackage = GetSlv.FullPackage;
                newSlave.Start_Fhp   = GetSlv.Start_Fhp;
                newSlave.Start_Dmg   = GetSlv.Start_Dmg;
                newSlave.Start_Acc   = GetSlv.Start_Acc;
                newSlave.Heal_Units  = GetSlv.Heal_Units;
                newSlave.Shot_Units  = GetSlv.Shot_Units;
                newSlave.Rush_Units  = GetSlv.Rush_Units;
                int GetStuffPlace = 0;
                GetSlv.InventoryPack.gameObject.active = true;
                foreach (Transform Place in GetSlv.InventoryPack.transform)
                {
                    if (Place.transform.childCount != 0)
                    {
                        GameObject GetItem = Place.transform.GetChild(0).gameObject;
                        if (GetItem.GetComponent <WeaponProperties>() != null)
                        {
                            ItemDoll         GetPlace = new ItemDoll();
                            WeaponProperties GetWpn   = GetItem.GetComponent <WeaponProperties>();
                            GetPlace.TypeOfItem = "Weapon";
                            GetPlace.Skin       = GetWpn.Skin;
                            GetPlace.Name       = GetWpn.WeapName;
                            GetPlace.Damage     = GetWpn.Damage;
                            GetPlace.Condition  = GetWpn.Condition;
                            GetPlace.Efficiency = GetWpn.Efficiency;
                            GetPlace.Price      = GetWpn.Price;
                            GetPlace.Bullets    = GetWpn.Bullets;
                            newSlave.Package[Place.transform.GetSiblingIndex()] = GetPlace;
                        }
                        if (GetItem.GetComponent <OtherStuff>() != null)
                        {
                            ItemDoll   GetPlace = new ItemDoll();
                            OtherStuff GetStf   = GetItem.GetComponent <OtherStuff>();
                            GetPlace.TypeOfItem = "Stuff";
                            GetPlace.Skin       = GetStf.Skin;
                            GetPlace.Price      = GetStf.Price;
                            GetPlace.Liters     = GetStf.Liters;
                            GetPlace.Name       = GetStf.Name;
                            newSlave.Package[Place.transform.GetSiblingIndex()] = GetPlace;
                        }
                    }
                }
            }
            else
            {
                newSlave.StatusEmpty = true;
            }
            newInventory.Slaves.Add(newSlave);
        }

        int NumPlace = 0;

        foreach (GameObject Item in PlayInv.Package)
        {
            if (Item != null)
            {
                if (Item.GetComponent <WeaponProperties>() != null)
                {
                    ItemDoll         GetPlace = new ItemDoll();
                    WeaponProperties GetWpn   = Item.GetComponent <WeaponProperties>();
                    GetPlace.TypeOfItem          = "Weapon";
                    GetPlace.Skin                = GetWpn.Skin;
                    GetPlace.Name                = GetWpn.WeapName;
                    GetPlace.Damage              = GetWpn.Damage;
                    GetPlace.Condition           = GetWpn.Condition;
                    GetPlace.Efficiency          = GetWpn.Efficiency;
                    GetPlace.Price               = GetWpn.Price;
                    GetPlace.Bullets             = GetWpn.Bullets;
                    newInventory.Items[NumPlace] = GetPlace;
                }
                if (Item.GetComponent <OtherStuff>() != null)
                {
                    ItemDoll   GetPlace = new ItemDoll();
                    OtherStuff GetStf   = Item.GetComponent <OtherStuff>();
                    GetPlace.TypeOfItem          = "Stuff";
                    GetPlace.Skin                = GetStf.Skin;
                    GetPlace.Price               = GetStf.Price;
                    GetPlace.Liters              = GetStf.Liters;
                    GetPlace.Name                = GetStf.Name;
                    newInventory.Items[NumPlace] = GetPlace;
                }
            }
            NumPlace += 1;
        }

        string       SaveData  = JsonUtility.ToJson(newInventory);
        StreamWriter WriteData = new StreamWriter(Application.persistentDataPath + "/PlayerData.json");

        WriteData.Write(SaveData);
        WriteData.Close();
    }
예제 #11
0
    //======================================================= LOAD INVENTORY ===========================================================

    public void LoadAll()
    {
        string       json     = File.ReadAllText(Application.persistentDataPath + "/PlayerData.json").ToString();
        PlayerSource LoadData = JsonUtility.FromJson <PlayerSource>(json);

        PlayInv.Money            = LoadData.Money;
        PlayInv.StoreID          = LoadData.CurrentStore;
        PlayInv.If_Tutorial      = LoadData.If_Tutorial;
        PlayInv.Step_Of_Tutorial = LoadData.Step_Of_Tutorial;

        int GetSlave = 0;

        foreach (SlaveDoll LoadSlave in LoadData.Slaves)
        {
            if (LoadSlave.StatusEmpty == false)
            {
                GameObject Slave = Instantiate(Resources.Load("HeroPrefab")) as GameObject;
                Slave.name = "Slv_" + GetSlave;
                SlaveProperties SlvProp = Slave.GetComponent <SlaveProperties>();
                SlvProp.Number      = LoadSlave.Number;
                SlvProp.Health      = LoadSlave.Health;
                SlvProp.FullHealth  = LoadSlave.FullHealth;
                SlvProp.Damage      = LoadSlave.Damage;
                SlvProp.Accuracy    = LoadSlave.Accuracy;
                SlvProp.Battles     = LoadSlave.Battles;
                SlvProp.Level       = LoadSlave.Level;
                SlvProp.Skin        = LoadSlave.Skin;
                SlvProp.Price       = LoadSlave.Price;
                SlvProp.Efficiency  = LoadSlave.Efficiency;
                SlvProp.WeaponSkin  = LoadSlave.WeaponSkin;
                SlvProp.HaveGun     = LoadSlave.HaveGun;
                SlvProp.FullPackage = LoadSlave.FullPackage;
                SlvProp.Start_Fhp   = LoadSlave.Start_Fhp;
                SlvProp.Start_Dmg   = LoadSlave.Start_Dmg;
                SlvProp.Start_Acc   = LoadSlave.Start_Acc;
                SlvProp.Shot_Units  = LoadSlave.Shot_Units;
                SlvProp.Heal_Units  = LoadSlave.Heal_Units;
                SlvProp.Rush_Units  = LoadSlave.Rush_Units;

                GameObject Pack      = SlvProp.InventoryPack.gameObject;
                int        PackPlace = 0;
                foreach (ItemDoll Item in LoadSlave.Package)
                {
                    if (Item != null)
                    {
                        if (Item.TypeOfItem == "Weapon")
                        {
                            GameObject       Wpn     = Instantiate(Resources.Load("WeaponDoll")) as GameObject;
                            WeaponProperties WpnProp = Wpn.GetComponent <WeaponProperties>();
                            WpnProp.Skin       = Item.Skin;
                            WpnProp.WeapName   = Item.Name;
                            WpnProp.Damage     = Item.Damage;
                            WpnProp.Condition  = Item.Condition;
                            WpnProp.Bullets    = Item.Bullets;
                            WpnProp.Efficiency = Item.Efficiency;
                            WpnProp.Price      = Item.Price;
                            WpnProp.Bought     = true;
                            Wpn.name           = WpnProp.WeapName + PackPlace;
                            Wpn.transform.SetParent(Pack.transform.GetChild(PackPlace).transform);
                            Wpn.transform.localPosition = new Vector3(0, 0, 0);
                            SlvProp.WeaponXRef          = Wpn;
                        }
                        if (Item.TypeOfItem == "Stuff")
                        {
                            GameObject Stuff   = Instantiate(Resources.Load("OtherStuff")) as GameObject;
                            OtherStuff StfProp = Stuff.GetComponent <OtherStuff>();
                            StfProp.Skin   = Item.Skin;
                            StfProp.Name   = Item.Name;
                            StfProp.Liters = Item.Liters;
                            StfProp.Price  = Item.Price;
                            StfProp.Bought = true;
                            Stuff.name     = StfProp.Name + PackPlace;
                            Stuff.transform.SetParent(Pack.transform.GetChild(PackPlace).transform);
                            Stuff.transform.localPosition = new Vector3(0, 0, 0);
                        }
                    }
                    PackPlace += 1;
                }

                PlayInv.SlavePlace[GetSlave] = Slave;
                Slave.transform.SetParent(SlaveSource.transform);
            }
            GetSlave += 1;
        }

        if (ItemsSource != null)
        {
            int NumItem = 0;
            foreach (ItemDoll Item in LoadData.Items)
            {
                if (Item != null)
                {
                    if (Item.TypeOfItem == "Weapon")
                    {
                        GameObject       Wpn     = Instantiate(Resources.Load("WeaponDoll")) as GameObject;
                        WeaponProperties WpnProp = Wpn.GetComponent <WeaponProperties>();
                        WpnProp.Skin             = Item.Skin;
                        WpnProp.WeapName         = Item.Name;
                        WpnProp.Damage           = Item.Damage;
                        WpnProp.Condition        = Item.Condition;
                        WpnProp.Bullets          = Item.Bullets;
                        WpnProp.Efficiency       = Item.Efficiency;
                        WpnProp.Price            = Item.Price;
                        WpnProp.Bought           = true;
                        Wpn.name                 = WpnProp.WeapName + NumItem;
                        PlayInv.Package[NumItem] = Wpn;
                        Wpn.transform.SetParent(ItemsSource.transform);
                        Wpn.transform.localPosition = new Vector3(0, 0, 0);
                    }
                    if (Item.TypeOfItem == "Stuff")
                    {
                        GameObject Stuff   = Instantiate(Resources.Load("OtherStuff")) as GameObject;
                        OtherStuff StfProp = Stuff.GetComponent <OtherStuff>();
                        StfProp.Skin             = Item.Skin;
                        StfProp.Name             = Item.Name;
                        StfProp.Liters           = Item.Liters;
                        StfProp.Price            = Item.Price;
                        StfProp.Bought           = true;
                        Stuff.name               = StfProp.Name + NumItem;
                        PlayInv.Package[NumItem] = Stuff;
                        Stuff.transform.SetParent(ItemsSource.transform);
                        Stuff.transform.localPosition = new Vector3(0, 0, 0);
                    }
                }
                NumItem += 1;
            }
        }
    }