alotta upgrade stuff but no upgrades
This commit is contained in:
parent
b9fb490dce
commit
3b60583c76
35 changed files with 2937 additions and 61 deletions
40
Assets/Scripts/Abilities/AbilityHotbarIcon.cs
Normal file
40
Assets/Scripts/Abilities/AbilityHotbarIcon.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class AbilityHotbarIcon : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject overlay;
|
||||
[SerializeField] private TextMeshProUGUI cooldownText;
|
||||
[SerializeField] private TextMeshProUGUI text;
|
||||
private bool onCooldown;
|
||||
private PlayerAbility thisAbility;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (onCooldown)
|
||||
{
|
||||
cooldownText.text = thisAbility.currentCooldown.ToString("F2");
|
||||
if (thisAbility.currentCooldown <= 0)
|
||||
{
|
||||
onCooldown = false;
|
||||
overlay.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCooldown()
|
||||
{
|
||||
if (thisAbility.currentCooldown > 0)
|
||||
{
|
||||
onCooldown = true;
|
||||
overlay.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAbility(PlayerAbility ability)
|
||||
{
|
||||
thisAbility = ability;
|
||||
text.text = thisAbility.abilityName;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/AbilityHotbarIcon.cs.meta
Normal file
2
Assets/Scripts/Abilities/AbilityHotbarIcon.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 18d0774d0a3b11b43858ef778057d6fe
|
||||
|
|
@ -31,10 +31,33 @@ public class AbilityManager : MonoBehaviour
|
|||
public Button upgradeButton;
|
||||
|
||||
[Header("Upgrades")]
|
||||
public List<StoredUpgrade> upgradesInventory;
|
||||
public HashSet<StoredUpgrade> upgradesInventory = new();
|
||||
private void Start()
|
||||
{
|
||||
upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
|
||||
// upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
|
||||
}
|
||||
|
||||
public void StoreUpgrade(AbilityUpgrade upgradeToStore)
|
||||
{
|
||||
foreach (StoredUpgrade storedUpgrade in upgradesInventory)
|
||||
{
|
||||
if (storedUpgrade.upgrade == upgradeToStore)
|
||||
{
|
||||
storedUpgrade.count++;
|
||||
Debug.Log($"Added upgrade {storedUpgrade.upgrade.upgradeName}. Current count: {storedUpgrade.count}");
|
||||
AbilityUIHandler.instance.UpdateInventory();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StoredUpgrade newUpgrade = new()
|
||||
{
|
||||
upgrade = upgradeToStore,
|
||||
count = 1
|
||||
};
|
||||
upgradesInventory.Add(newUpgrade);
|
||||
Debug.Log($"Added upgrade {newUpgrade.upgrade.upgradeName}. Current count: {newUpgrade.count}");
|
||||
AbilityUIHandler.instance.UpdateInventory();
|
||||
}
|
||||
|
||||
public void AddUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,29 @@ using UnityEngine;
|
|||
|
||||
public class AbilityUIHandler : MonoBehaviour
|
||||
{
|
||||
public List<AbilityUIObject> uiObjects = new();
|
||||
#region Statication
|
||||
|
||||
public static AbilityUIHandler instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
[Header("Abilities")]
|
||||
public List<AbilityUIObject> uiObjects = new();
|
||||
[SerializeField] private MarisaAbilityHandler playerAbilityHandler;
|
||||
|
||||
[Header("Upgrades")]
|
||||
[SerializeField] private Transform upgradeGrid;
|
||||
[SerializeField] private StoredAbilityUpgradeUI templateStoredUpgradeUI;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
uiObjects[0].thisAbility = playerAbilityHandler.mainAttackInstance;
|
||||
|
|
@ -19,4 +38,17 @@ public class AbilityUIHandler : MonoBehaviour
|
|||
uiObject.UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInventory()
|
||||
{
|
||||
foreach (Transform child in upgradeGrid) //awful but we'll go with it for now
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
foreach (AbilityManager.StoredUpgrade storedUpgrade in AbilityManager.instance.upgradesInventory)
|
||||
{
|
||||
StoredAbilityUpgradeUI newUI = Instantiate(templateStoredUpgradeUI, upgradeGrid);
|
||||
newUI.SetUpgrade(storedUpgrade.upgrade, storedUpgrade.count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class Laser : PlayerAbility
|
|||
{
|
||||
canCooldown = false;
|
||||
currentDuration = duration;
|
||||
currentCooldown = cooldown;
|
||||
currentDebounce = damageDebounceTime;
|
||||
beamObjectInstance.gameObject.SetActive(true);
|
||||
transform.Lookat2D(thisPlayer.mouseWorldPos);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class NondirectionalLaser : Laser
|
|||
{
|
||||
canCooldown = false;
|
||||
currentDuration = duration;
|
||||
currentCooldown = cooldown;
|
||||
currentDebounce = damageDebounceTime;
|
||||
beamRoot.gameObject.SetActive(true);
|
||||
}
|
||||
|
|
@ -40,6 +41,7 @@ public class NondirectionalLaser : Laser
|
|||
}
|
||||
currentDebounce = damageDebounceTime;
|
||||
}
|
||||
currentDuration -= Time.deltaTime;
|
||||
}
|
||||
if (currentDuration <= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class PlayerAbility : MonoBehaviour
|
|||
[Header("Cooldown")]
|
||||
public bool canCooldown = true;
|
||||
public float cooldown;
|
||||
protected float currentCooldown;
|
||||
public float currentCooldown;
|
||||
[Header("Stats")]
|
||||
public float power;
|
||||
public float projectileCount;
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class UpgradePickup : ItemPickup
|
||||
{
|
||||
public AbilityUpgrade upgradeDropped;
|
||||
protected override void PickupEffects()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,8 @@ public class Enemy : Entity
|
|||
}
|
||||
[Header("Drops")]
|
||||
public List<UpgradeDrop> possibleDrops = new();
|
||||
|
||||
[SerializeField] private UpgradePickup pickupObject;
|
||||
private void Start()
|
||||
{
|
||||
if (Random.Range(0f, 2f) > 1f)
|
||||
|
|
@ -82,7 +84,8 @@ public class Enemy : Entity
|
|||
{
|
||||
if (random < drop.chance) //just so it matches up with the number. 80 chance means 80 percent? idk but less than 80 lol
|
||||
{
|
||||
// drop the item
|
||||
UpgradePickup newPickup = Instantiate(pickupObject, transform.position, Quaternion.identity);
|
||||
newPickup.upgradeDropped = drop.droppedUpgrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,27 @@ public class MarisaAbilityHandler : MonoBehaviour
|
|||
public PlayerAbility spellAInstance;
|
||||
public PlayerAbility spellBInstance;
|
||||
|
||||
[Header("UI")]
|
||||
public AbilityHotbarIcon mainIcon;
|
||||
public AbilityHotbarIcon secondaryIcon;
|
||||
public AbilityHotbarIcon spellAIcon;
|
||||
public AbilityHotbarIcon spellBIcon;
|
||||
//this is getting ridiculous
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mainAttackInstance = Instantiate(mainAttack, transform);
|
||||
mainAttackInstance.thisPlayer = thisPlayer;
|
||||
mainIcon.UpdateAbility(mainAttackInstance);
|
||||
secondaryAttackInstance = Instantiate(secondaryAttack, transform);
|
||||
secondaryAttackInstance.thisPlayer = thisPlayer;
|
||||
secondaryIcon.UpdateAbility(secondaryAttackInstance);
|
||||
spellAInstance = Instantiate(spellA, transform);
|
||||
spellAInstance.thisPlayer = thisPlayer;
|
||||
spellAIcon.UpdateAbility(spellAInstance);
|
||||
spellBInstance = Instantiate(spellB, transform);
|
||||
spellBInstance.thisPlayer = thisPlayer;
|
||||
spellBIcon.UpdateAbility(spellBInstance);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
|
@ -35,18 +46,22 @@ public class MarisaAbilityHandler : MonoBehaviour
|
|||
if (inputHandler.actions["MainAttack"].inProgress)
|
||||
{
|
||||
mainAttackInstance.TryAbility();
|
||||
mainIcon.UpdateCooldown();
|
||||
}
|
||||
else if (inputHandler.actions["SecondaryAttack"].inProgress)
|
||||
{
|
||||
secondaryAttackInstance.TryAbility();
|
||||
secondaryIcon.UpdateCooldown();
|
||||
}
|
||||
else if (inputHandler.actions["SpellA"].inProgress)
|
||||
{
|
||||
spellAInstance.TryAbility();
|
||||
spellAIcon.UpdateCooldown();
|
||||
}
|
||||
else if (inputHandler.actions["SpellB"].inProgress)
|
||||
{
|
||||
spellBInstance.TryAbility();
|
||||
spellBIcon.UpdateCooldown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,16 @@ public class ItemPickup : MonoBehaviour
|
|||
{
|
||||
if (inRange)
|
||||
{
|
||||
rb.linearVelocity = (transform.position - AbilityManager.instance.player.transform.position).normalized * speed;
|
||||
rb.linearVelocity = (AbilityManager.instance.player.transform.position - transform.position).normalized * speed;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
PickupEffects();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
protected virtual void PickupEffects()
|
||||
public virtual void PickupEffects()
|
||||
{
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ public class ItemPickupRange : MonoBehaviour
|
|||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
thisItem.inRange = true;
|
||||
if (other.CompareTag(tag))
|
||||
{
|
||||
thisItem.inRange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ using UnityEngine;
|
|||
public class PowerPickup : ItemPickup
|
||||
{
|
||||
[SerializeField] private float powerAmount;
|
||||
protected override void PickupEffects()
|
||||
public override void PickupEffects()
|
||||
{
|
||||
|
||||
base.PickupEffects();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
Assets/Scripts/Items/UpgradePickup.cs
Normal file
11
Assets/Scripts/Items/UpgradePickup.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class UpgradePickup : ItemPickup
|
||||
{
|
||||
public AbilityUpgrade upgradeDropped;
|
||||
public override void PickupEffects()
|
||||
{ //i'll figure out the hashset later
|
||||
base.PickupEffects();
|
||||
AbilityManager.instance.StoreUpgrade(upgradeDropped);
|
||||
}
|
||||
}
|
||||
15
Assets/Scripts/Items/UpgradePickupEffects.cs
Normal file
15
Assets/Scripts/Items/UpgradePickupEffects.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class UpgradePickupEffects : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private UpgradePickup thisPickup;
|
||||
|
||||
public void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag(tag))
|
||||
{
|
||||
thisPickup.PickupEffects();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Items/UpgradePickupEffects.cs.meta
Normal file
2
Assets/Scripts/Items/UpgradePickupEffects.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3826d3871547e566aa448bea0f340014
|
||||
17
Assets/Scripts/StoredAbilityUpgradeUI.cs
Normal file
17
Assets/Scripts/StoredAbilityUpgradeUI.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StoredAbilityUpgradeUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image icon;
|
||||
[SerializeField] private TextMeshProUGUI nameUI;
|
||||
[SerializeField] private TextMeshProUGUI countUI;
|
||||
|
||||
public void SetUpgrade(AbilityUpgrade upgrade, int count)
|
||||
{
|
||||
//icon.sprite = upgrade.upgradeIcon;
|
||||
nameUI.text = upgrade.name;
|
||||
countUI.text = $"x{count}";
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/StoredAbilityUpgradeUI.cs.meta
Normal file
2
Assets/Scripts/StoredAbilityUpgradeUI.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b370a84d98c02cd8aac5802018918417
|
||||
14
Assets/Scripts/UIHandler.cs
Normal file
14
Assets/Scripts/UIHandler.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class UIHandler : MonoBehaviour
|
||||
{
|
||||
public void ShowUI(GameObject shownUI)
|
||||
{
|
||||
shownUI.SetActive(true);
|
||||
}
|
||||
|
||||
public void HideUI(GameObject hiddenUI)
|
||||
{
|
||||
hiddenUI.SetActive(false);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UIHandler.cs.meta
Normal file
2
Assets/Scripts/UIHandler.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2fcbf7ba7b9dd4a4f830085cba33ae91
|
||||
Loading…
Add table
Add a link
Reference in a new issue