void ChangeAttributeLevelByOne( int attributeIndex, bool increment ) { if (PlayerDataIsLoaded()) { int equippedBowIndex = GetEquippedBowIndex(); IBowConfigData configData = GetBowConfigDataArray()[equippedBowIndex]; int[] attributeLevels = configData.GetAttributeLevels(); int currentAttributeLevel = attributeLevels[attributeIndex]; int newAttributeLevel = increment? currentAttributeLevel + 1: currentAttributeLevel - 1; if (newAttributeLevel > thisMaxAttributeLevel) { newAttributeLevel = thisMaxAttributeLevel; } else if (newAttributeLevel < 0) { newAttributeLevel = 0; } int[] newAttributeLevels = attributeLevels; newAttributeLevels[attributeIndex] = newAttributeLevel; configData.SetAttributeLevels(newAttributeLevels); } else { throw new System.InvalidOperationException( "no player data" ); } }
void DrawBowControl(Rect rect) { if (thisSystemIsReady) { IPlayerDataManager playerDataManager = playerDataManagerAdaptor.GetPlayerDataManager(); if (playerDataManager.PlayerDataIsLoaded()) { //unlock, equip Rect sub_0 = GetHorizontalSubRect(rect, 0, 2); Rect sub_1 = GetHorizontalSubRect(rect, 1, 2); IBowConfigData bowConfigData = playerDataManager.GetBowConfigDataArray()[thisSelectedBowIndex]; bool isUnlocked = bowConfigData.IsUnlocked(); string lockToggleButtonText = isUnlocked ? "Lock" : "Unlock"; if (GUI.Button( sub_0, lockToggleButtonText )) { if (isUnlocked) { playerDataManager.LockBow(thisSelectedBowIndex); } else { playerDataManager.UnlockBow(thisSelectedBowIndex); } } int equippedBowIndex = playerDataManager.GetEquippedBowIndex(); if (equippedBowIndex == thisSelectedBowIndex) { GUI.Box( sub_1, "Equipped" ); } else { if (GUI.Button( sub_1, "Equip" )) { playerDataManager.SetEquippedBow(thisSelectedBowIndex); } } } else { GUI.Box( rect, "bow control\n" + "playerData not ready" ); } } }
void UpdateAttributePanel( IBowPanel bowPanel, IBowConfigData bowConfigData ) { int[] attributeLevels = bowConfigData.GetAttributeLevels(); int bowIndex = bowPanel.GetIndex(); int attributeIndex = 0; foreach (int attributeLevel in attributeLevels) { bowPanel.SetAttributeLevel( attributeIndex, attributeLevel, true ); IBowAttributeLevelUpHoldButton levelUpButton = bowPanel.GetBowAttributeLevelUpHoldButtons()[attributeIndex]; if (attributeLevel == thisPlayerDataManager.GetMaxAttributeLevel()) { levelUpButton.MaxOut(); } else { int nextLevel = attributeLevel + 1; int nextCost = CalculateCost( bowIndex, nextLevel ); levelUpButton.SetNextCost(nextCost); int currency = thisPlayerDataManager.GetCurrency(); if (currency < nextCost) { levelUpButton.InvalidateForShortMoney(); } else { levelUpButton.ValidateForLevelUp(); } } attributeIndex += 1; } int equippedBowIndex = thisPlayerDataManager.GetEquippedBowIndex(); Debug.Log( "BowPanel " + bowPanel.GetIndex().ToString() + ", " + "unlocked: " + bowConfigData.IsUnlocked().ToString() + ", " + "equipped: " + (bowIndex == equippedBowIndex).ToString() + ", " + "bowLevel: " + bowConfigData.GetBowLevel().ToString() + ", " + "attLevels: " + DKUtility.DebugHelper.GetIndicesString(attributeLevels) ); }
public void LockBow(int bowIndex) { if (PlayerDataIsLoaded()) { IBowConfigData configData = GetBowConfigDataArray()[bowIndex]; configData.Lock(); } else { throw new System.InvalidOperationException( "no player data" ); } }
IBowConfigData[] CreateInitializedBowCofigDataArray() { IBowConfigData[] result = new IBowConfigData[thisBowCount]; for (int i = 0; i < thisBowCount; i++) { IBowConfigData configData = new BowConfigData(); int[] attributeLevelArray = new int[] { 0, 0, 0 }; configData.SetAttributeLevels(attributeLevelArray); result[i] = configData; } result[0].Unlock(); return(result); }
public void CalculateShootingData() { int equippedBowIndex = thisPlayerDataManager.GetEquippedBowIndex(); IBowConfigData bowConfigData = thisPlayerDataManager.GetBowConfigDataArray()[equippedBowIndex]; int[] attributeLevels = bowConfigData.GetAttributeLevels(); float strengthValue = thisCalculator.GetAttributeValue(attributeLevels[0]); float quicknessValue = thisCalculator.GetAttributeValue(attributeLevels[1]); float criticalValue = thisCalculator.GetAttributeValue(attributeLevels[2]); thisMinDrawStrength = CalculateMinDrawStrength(strengthValue); thisMaxDrawStrength = CalculateMaxDrawStrength(strengthValue); thisFireRate = CalculateFireRate(quicknessValue); thisDrawTime = CalculateDrawTime(quicknessValue); thisCritMultiplier = CalculateCriticalMultiplier(criticalValue); }
int CalculateCost( int bowIndex, int level ) { IBowConfigData bowConfigData = thisPlayerDataManager.GetBowConfigDataArray()[bowIndex]; int[] levels = bowConfigData.GetAttributeLevels(); float coinDepreValue = CalculateCoinDepreciationValue( levels, thisCalculator ); int cost = thisCalculator.CalcCost( level, coinDepreValue ); return(cost); }
void UpdateUnlockButtons() { int currency = thisPlayerDataManager.GetCurrency(); foreach (IBowUnlockButton unlockButton in thisBowUnlockButtons) { int index = unlockButton.GetPanelIndex(); IBowConfigData configData = thisPlayerDataManager.GetBowConfigDataArray()[index]; if (!configData.IsUnlocked()) { int unlockCost = thisPlayerDataManager.GetBowUnlockCostArray()[index]; if (currency < unlockCost) { unlockButton.InvalidateForShortMoney(); } else { unlockButton.ValidateForUnlock(); } } } }
public void UnlockPanel(int index) { if (!thisPlayerDataManager.PlayerDataIsLoaded()) { thisPlayerDataManager.Load(); } IBowConfigData data = thisPlayerDataManager.GetBowConfigDataArray()[index]; data.Unlock(); int currency = thisPlayerDataManager.GetCurrency(); int cost = thisPlayerDataManager.GetBowUnlockCostArray()[index]; int newCurrency = currency - cost; UpdateCurrency(newCurrency); TrySetEquippedBow(index); IBowPanel panel = thisBowPanels[index]; panel.Unlock(false); }
public void IncreaseAttributeLevel(int attributeIndex) { if (!thisPlayerDataManager.PlayerDataIsLoaded()) { thisPlayerDataManager.Load(); } thisPlayerDataManager.IncreaseAttributeLevel(attributeIndex); int equippedBowIndex = thisPlayerDataManager.GetEquippedBowIndex(); IBowPanel panel = thisBowPanels[equippedBowIndex]; IBowConfigData[] dataArray = thisPlayerDataManager.GetBowConfigDataArray(); IBowConfigData data = dataArray[equippedBowIndex]; int bowLevel = data.GetBowLevel(); panel.SetBowLevel(bowLevel, false); IBowAttributeLevelUpHoldButton button = panel.GetBowAttributeLevelUpHoldButtons()[attributeIndex]; int currency = thisPlayerDataManager.GetCurrency(); int newCurrency = currency - button.GetCost(); UpdateCurrency(newCurrency); foreach (IBowPanel bowPanel in thisBowPanels) { IBowConfigData configData = dataArray[bowPanel.GetIndex()]; UpdateAttributePanel( bowPanel, configData ); } UpdateUnlockButtons(); thisPlayerDataManager.Save(); }
/* Data Manipulation */ public void TrySetEquippedBow(int index) { if (!thisPlayerDataManager.PlayerDataIsLoaded()) { thisPlayerDataManager.Load(); } int prevEquippedBowIndex = thisPlayerDataManager.GetEquippedBowIndex(); if (prevEquippedBowIndex != index) { IBowConfigData configData = thisPlayerDataManager.GetBowConfigDataArray()[index]; if (configData.IsUnlocked()) { thisPlayerDataManager.SetEquippedBow(index); thisPlayerDataManager.Save(); IBowPanel panelToEquip = thisBowPanels[index]; IBowPanel panelToUnequip = thisBowPanels[prevEquippedBowIndex]; panelToEquip.SetEquippedness(true, false); panelToUnequip.SetEquippedness(false, false); } } }
void LoadAndFeedAllPanelsWithPlayerData() { thisPlayerDataManager.SetFileIndex(0); thisPlayerDataManager.Load(); int equippedBowIndex = thisPlayerDataManager.GetEquippedBowIndex(); IBowConfigData[] configDataArray = thisPlayerDataManager.GetBowConfigDataArray(); foreach (IBowPanel bowPanel in thisBowPanels) { int bowIndex = bowPanel.GetIndex(); IBowConfigData bowConfigData = configDataArray[bowIndex]; if (!bowConfigData.IsUnlocked()) { bowPanel.Lock(instantly: true); } else { bowPanel.Unlock(instantly: true); } if (bowIndex == equippedBowIndex) { bowPanel.SetEquippedness(isEquipped: true, instantly: true); } else { bowPanel.SetEquippedness(isEquipped: false, instantly: true); } int bowLevel = bowConfigData.GetBowLevel(); bowPanel.SetBowLevel(bowLevel, instantly: false); UpdateAttributePanel(bowPanel, bowConfigData); } UpdateUnlockButtons(); }