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" ); } } }
/* 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); } } }