diff options
| author | chai <215380520@qq.com> | 2024-05-19 16:05:01 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-19 16:05:01 +0800 |
| commit | c5f145786f4c6d2fe4bea831dfc16e52228920a5 (patch) | |
| tree | a6ead7ea8266c767d58ed0f816dcd7a1dd75bd65 /GameCode/PerkSelectionGroup.cs | |
| parent | 48b64e573a1709dc923cb9162b55be0246b3ff63 (diff) | |
* move
Diffstat (limited to 'GameCode/PerkSelectionGroup.cs')
| -rw-r--r-- | GameCode/PerkSelectionGroup.cs | 165 |
1 files changed, 0 insertions, 165 deletions
diff --git a/GameCode/PerkSelectionGroup.cs b/GameCode/PerkSelectionGroup.cs deleted file mode 100644 index 06d1131..0000000 --- a/GameCode/PerkSelectionGroup.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System.Collections.Generic; -using TMPro; -using UnityEngine; - -public class PerkSelectionGroup : MonoBehaviour -{ - private enum Type - { - Weapons, - Perks, - Mutations, - FixedLoadout - } - - public GameObject perkSelectionItemPrefab; - - public GameObject perkLockedPrefab; - - [SerializeField] - private Type type; - - private PerkManager perkManager; - - private int selectableAmount = 10000; - - private List<PerkSelectionItem> selectedInMyGroup = new List<PerkSelectionItem>(); - - [SerializeField] - private TMP_Text headerText; - - [SerializeField] - private string selectNone = "No perks unlocked yet."; - - [SerializeField] - private string selectOne = "Select one perk."; - - [SerializeField] - private string selectMulti = "Select <n> perks."; - - [SerializeField] - private bool canDeselectPerks = true; - - [SerializeField] - private Color textColorNormal = Color.white; - - [SerializeField] - private Color textColorWarning = Color.red; - - private int unlockedPerks; - - private void Start() - { - UpdateVisuals(); - } - - public void UpdateVisuals() - { - perkManager = PerkManager.instance; - int num = 0; - for (int num2 = base.transform.childCount - 1; num2 >= 0; num2--) - { - Object.Destroy(base.transform.GetChild(num2).gameObject); - } - unlockedPerks = 0; - for (int i = 0; i < perkManager.UnlockedEquippables.Count; i++) - { - Equippable equippable = perkManager.UnlockedEquippables[i]; - if (equippable.GetType() == typeof(PerkPoint)) - { - num++; - } - if ((type == Type.Weapons && equippable.GetType() == typeof(EquippableWeapon)) || (type == Type.Perks && equippable.GetType() == typeof(EquippablePerk)) || (type == Type.Mutations && equippable.GetType() == typeof(EquippableMutation))) - { - Object.Instantiate(perkSelectionItemPrefab, base.transform).GetComponent<PerkSelectionItem>().Initialize(equippable); - unlockedPerks++; - } - } - for (int j = 0; j < perkManager.MetaLevels.Count; j++) - { - Equippable reward = perkManager.MetaLevels[j].reward; - if (((type == Type.Weapons && reward.GetType() == typeof(EquippableWeapon)) || (type == Type.Perks && reward.GetType() == typeof(EquippablePerk)) || (type == Type.Mutations && reward.GetType() == typeof(EquippableMutation))) && !perkManager.UnlockedEquippables.Contains(reward)) - { - Object.Instantiate(perkLockedPrefab, base.transform); - } - } - if (type == Type.FixedLoadout && LevelInteractor.lastActivatedLevelInteractor != null) - { - selectableAmount = 0; - LevelInteractor lastActivatedLevelInteractor = LevelInteractor.lastActivatedLevelInteractor; - for (int k = 0; k < lastActivatedLevelInteractor.fixedLoadout.Count; k++) - { - Equippable equippable2 = lastActivatedLevelInteractor.fixedLoadout[k]; - PerkSelectionItem component = Object.Instantiate(perkSelectionItemPrefab, base.transform).GetComponent<PerkSelectionItem>(); - component.Selected = true; - component.Initialize(equippable2); - selectableAmount++; - } - } - if (type == Type.Weapons) - { - selectableAmount = 1; - } - if (type == Type.Perks) - { - selectableAmount = num; - } - if (type == Type.Mutations) - { - selectableAmount = 10000; - } - if (selectableAmount <= 0 || unlockedPerks <= 0) - { - headerText.text = selectNone; - } - else if (selectableAmount == 1) - { - headerText.text = selectOne; - } - else - { - headerText.text = selectMulti.Replace("<n>", selectableAmount.ToString()); - } - } - - private void Update() - { - if (selectedInMyGroup.Count < Mathf.Min(unlockedPerks, selectableAmount)) - { - headerText.color = textColorWarning; - } - else - { - headerText.color = textColorNormal; - } - } - - public void SelectPerk(PerkSelectionItem _selectedPerk) - { - if (!canDeselectPerks && _selectedPerk.Selected) - { - return; - } - _selectedPerk.Selected = !_selectedPerk.Selected; - if (_selectedPerk.Selected) - { - selectedInMyGroup.Add(_selectedPerk); - if (!perkManager.CurrentlyEquipped.Contains(_selectedPerk.Equippable)) - { - perkManager.CurrentlyEquipped.Add(_selectedPerk.Equippable); - } - if (selectedInMyGroup.Count > selectableAmount) - { - PerkSelectionItem perkSelectionItem = selectedInMyGroup[0]; - perkSelectionItem.Selected = false; - selectedInMyGroup.Remove(perkSelectionItem); - perkManager.CurrentlyEquipped.Remove(perkSelectionItem.Equippable); - } - } - else - { - selectedInMyGroup.Remove(_selectedPerk); - perkManager.CurrentlyEquipped.Remove(_selectedPerk.Equippable); - } - } -} |
