//Updates the UI protected virtual void UpdateTankStats(int index) { TankTypeDefinition tankData = TankLibrary.s_Instance.GetTankDataForIndex(index); if (m_Capitalize) { m_TankName.text = tankData.name.ToUpperInvariant(); } else { m_TankName.text = tankData.name; } if (m_SpeedSlider != null) { m_SpeedSlider.UpdateValue(tankData.speedRating); } if (m_RefireRateSlider != null) { m_RefireRateSlider.UpdateValue(tankData.refireRating); } if (m_ArmorSlider != null) { m_ArmorSlider.UpdateValue(tankData.armourRating); } }
/// <summary> /// DEPRECATED: Temporarily unlocks this tank in response to watching an advert. /// </summary> private void TempUnlockTank() { TankTypeDefinition tankData = TankLibrary.s_Instance.GetTankDataForIndex(m_CurrentIndex); DailyUnlockManager.s_Instance.SetDailyUnlock(tankData.id); UpdateTankStats(m_CurrentIndex); }
/// <summary> /// Changes the star ratings for different tank statistics based on the tank index. /// </summary> /// <param name="index">Index of the selected tank in the TankLibrary.</param> protected override void UpdateTankStats(int index) { TankTypeDefinition tankData = TankLibrary.s_Instance.GetTankDataForIndex(index); m_TankDescription.text = tankData.description; m_Cost.text = tankData.cost.ToString(); bool isLocked = (!PlayerDataManager.s_Instance.IsTankUnlocked(index) && !DailyUnlockManager.s_Instance.IsItemTempUnlocked(tankData.id)); m_LockedPanel.SetActive(isLocked); m_OkButton.interactable = !isLocked; base.UpdateTankStats(index); }
//As this class is recreated each time we enter the menu from another scene, we can rely on Start to refresh our selections. private IEnumerator Start() { //Alas, we must wait for the Daily unlock manager to be initialized before we can poll it for temp unlock data. while (!DailyUnlockManager.s_Instance.IsInitialized()) { yield return(null); } //Check if the last selected tank is still valid for selection. If not, reset to default. int testIndex = PlayerDataManager.s_Instance.selectedTank; TankTypeDefinition tankData = TankLibrary.s_Instance.GetTankDataForIndex(testIndex); if (!PlayerDataManager.s_Instance.IsTankUnlocked(testIndex) && !DailyUnlockManager.s_Instance.IsItemTempUnlocked(tankData.id)) { testIndex = 0; PlayerDataManager.s_Instance.selectedTank = 0; } //Loads correct tank LoadModelForTankIndex(testIndex); }
//Loads the correct tank model public void LoadModelForTankIndex(int definitionIndex) { TankTypeDefinition tankData = TankLibrary.s_Instance.GetTankDataForIndex(definitionIndex); ChangeTankModel(tankData.displayPrefab); }
/// <summary> /// Brings up the Buy modal, which will determine whether the tank can be purchased with in-game currency. /// </summary> public void TryBuyCurrentTank() { TankTypeDefinition tankData = TankLibrary.s_Instance.GetTankDataForIndex(m_CurrentIndex); m_BuyModal.OpenBuyModal(tankData.name, tankData.cost, BuyCurrentTank, TempUnlockTank); }