public ShooterData(int coins, ShooterAmor amor, Shield shield, List <HighScore> highScoreTable)
 {
     this.CoinsInHand      = coins;
     this.Amor             = amor;
     this.CurrentShield    = shield;
     this.m_HighScoreTable = highScoreTable;
 }
Beispiel #2
0
        /// <summary>
        /// Initialized the shop data
        /// </summary>
        void Init()
        {
            int coinsInHand = GameManager.Instance.GetCoinsInHand();

            m_ShooterAmor = GameManager.Instance.GetCurrentAmorData();

            m_Coins.text = coinsInHand.ToString();

            int nextGunPowerCost   = GetNextGunCost(m_ShooterAmor.GunLevel);
            int nextMissileMagCost = GetNextMissileMagazineCost(m_ShooterAmor.MissileMagazineLvl);


            //////
            // Set Gun Power Related Stuff
            //////
            m_GunPowerSlider.maxValue    = DataBank.GetGunPowerData().Count();
            m_GunPowerSlider.value       = m_ShooterAmor.GunLevel;
            m_GunUpgradeBtn.interactable = SetButtonIntractable(nextGunPowerCost, coinsInHand);
            m_GunPowerInfo.text          = GetGunPowerInfoText(m_ShooterAmor.GunLevel);

            //////
            // Set Missile Magazine Related Stuff
            //////
            m_MagazineSlider.maxValue       = DataBank.GetMissileMagazineData().Count();
            m_MagazineSlider.value          = m_ShooterAmor.MissileMagazineLvl;
            m_MagazineUpgrdBtn.interactable = SetButtonIntractable(nextMissileMagCost, coinsInHand);
            m_MagazineInfo.text             = GetMagazineInfoText(m_ShooterAmor.MissileMagazineLvl);

            //////
            // Set Missile Related Stuff
            //////
            int missileCount = m_ShooterAmor.MissileCount;
            int missileCap   = m_ShooterAmor.MagazineCapacity;

            m_MissileSlider.maxValue     = missileCap;
            m_MissileSlider.value        = missileCount;
            m_MissileCount.text          = "Missile Count:" + missileCount + "/" + missileCap;
            m_MissileAddBtn.interactable = SetButtonIntractable(m_MissileCost, coinsInHand);
            m_MissileInfoText.text       = GetMissileCapacityInfoText();


            //////
            // Set Shield Related Stuff
            //////
            int shieldLvl  = GetCurrentShieldLevel(GameManager.Instance.GetCurrentShield().Duration);
            int shieldCost = GetNextShieldCost(shieldLvl);

            m_ShiledSlider.maxValue  = DataBank.GetShieldData().Count();
            m_ShiledSlider.value     = shieldLvl;
            m_ShieldInfo.text        = GetShieldInfoText(shieldLvl);
            m_ShieldBtn.interactable = SetButtonIntractable(shieldCost, coinsInHand);

            //////
            // Set Life Related Stuff
            //////
            m_LifeSlider.value     = GameManager.Instance.LifesLeft();
            m_LifeBtn.interactable = SetButtonIntractable(m_LifeCost, coinsInHand);
            m_LifeInfo.text        = GetLifeInfoText(GameManager.Instance.LifesLeft());
        }
        /// <summary>
        /// Get Saved Data
        /// </summary>
        void ReadSavedData()
        {
            string shooterData = PlayerPrefs.GetString(m_ShooterDataKey, null);

            if (string.IsNullOrEmpty(shooterData))
            {
                ShooterAmor amor   = new ShooterAmor(1, 1, 1, 1);
                Shield      shield = new Shield(0, 3);
                ShooterData data   = new ShooterData(0, amor, shield, LoadDummyData());

                m_ShooterData = data;
            }
            else
            {
                m_ShooterData = JsonUtility.FromJson <ShooterData>(shooterData);
            }
        }