more enemy stuff
This commit is contained in:
parent
3b60583c76
commit
d8c49317a3
235 changed files with 27781 additions and 3909 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ public class AbilityManager : MonoBehaviour
|
|||
private void Start()
|
||||
{
|
||||
// upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
|
||||
StoreUpgrade(upgradeToAdd);
|
||||
}
|
||||
|
||||
public void StoreUpgrade(AbilityUpgrade upgradeToStore)
|
||||
|
|
@ -59,23 +61,34 @@ public class AbilityManager : MonoBehaviour
|
|||
Debug.Log($"Added upgrade {newUpgrade.upgrade.upgradeName}. Current count: {newUpgrade.count}");
|
||||
AbilityUIHandler.instance.UpdateInventory();
|
||||
}
|
||||
|
||||
public void AddUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
|
||||
{
|
||||
if (!ability.attachedUpgrades.Contains(upgrade))
|
||||
foreach (StoredUpgrade storedUpgrade in upgradesInventory.ToArray())
|
||||
{
|
||||
AbilityUpgrade newUpgrade = Instantiate(upgrade, ability.transform);
|
||||
ability.attachedUpgrades.Add(newUpgrade);
|
||||
newUpgrade.thisPlayerAbility = ability;
|
||||
newUpgrade.ApplyUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
ability.attachedUpgrades.TryGetValue(upgrade, out AbilityUpgrade foundUpgrade);
|
||||
if (foundUpgrade)
|
||||
if (storedUpgrade.upgrade == upgrade)
|
||||
{
|
||||
foundUpgrade.count++;
|
||||
foundUpgrade.ApplyUpgrade();
|
||||
storedUpgrade.count--;
|
||||
if (storedUpgrade.count <= 0)
|
||||
{
|
||||
upgradesInventory.Remove(storedUpgrade);
|
||||
AbilityUIHandler.instance.UpdateInventory();
|
||||
}
|
||||
if (!ability.attachedUpgrades.Contains(upgrade))
|
||||
{
|
||||
AbilityUpgrade newUpgrade = Instantiate(upgrade, ability.transform);
|
||||
ability.attachedUpgrades.Add(newUpgrade);
|
||||
newUpgrade.thisPlayerAbility = ability;
|
||||
newUpgrade.ApplyUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
ability.attachedUpgrades.TryGetValue(upgrade, out AbilityUpgrade foundUpgrade);
|
||||
if (foundUpgrade)
|
||||
{
|
||||
foundUpgrade.count++;
|
||||
foundUpgrade.ApplyUpgrade();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
|
@ -15,6 +16,7 @@ public class AbilityUIObject : MonoBehaviour
|
|||
[SerializeField] private TextMeshProUGUI piercing;
|
||||
[SerializeField] private TextMeshProUGUI projectileCount;
|
||||
[Header("Upgrades")]
|
||||
[SerializeField] private int upgradeSlotAmount;
|
||||
[SerializeField] private UpgradeBoxUI templateUpgradeBox;
|
||||
[SerializeField] private Transform upgradeGrid;
|
||||
[SerializeField] private List<UpgradeBoxUI> upgradeBoxes = new();
|
||||
|
|
@ -32,14 +34,30 @@ public class AbilityUIObject : MonoBehaviour
|
|||
piercing.text = $"Piercing: {isBullet.pierceAmount}";
|
||||
projectileCount.text = $"Projectiles: {isBullet.projectileCount}";
|
||||
}
|
||||
foreach (AbilityUpgrade upgrade in thisAbility.attachedUpgrades)
|
||||
{
|
||||
AddUpgradeBox(upgrade);
|
||||
}
|
||||
|
||||
int upgradeBoxesToAdd = Math.Abs(upgradeSlotAmount - upgradeBoxes.Count);
|
||||
for (int i = 0; i < upgradeBoxesToAdd; i++)
|
||||
{
|
||||
AddUpgradeBox(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddUpgradeBox(AbilityUpgrade upgrade)
|
||||
{
|
||||
UpgradeBoxUI newBox = Instantiate(templateUpgradeBox, upgradeGrid);
|
||||
newBox.gameObject.SetActive(true);
|
||||
upgradeBoxes.Add(newBox);
|
||||
newBox.upgradeImage.sprite = upgrade.upgradeIcon;
|
||||
newBox.UpdateCounter();
|
||||
newBox.thisPlayerAbility = thisAbility;
|
||||
if (upgrade)
|
||||
{
|
||||
newBox.upgradeImage.sprite = upgrade.upgradeIcon;
|
||||
newBox.thisAbilityUpgrade = upgrade;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUpgradeBoxes()
|
||||
|
|
|
|||
11
Assets/Scripts/Abilities/EnemyAbility.cs
Normal file
11
Assets/Scripts/Abilities/EnemyAbility.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class EnemyAbility : ScriptableObject
|
||||
{
|
||||
public float cooldown;
|
||||
public float power;
|
||||
public virtual void UseAbility(Entity target, Enemy owner)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/EnemyAbility.cs.meta
Normal file
2
Assets/Scripts/Abilities/EnemyAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e3e75d1221694242192a35134c73e473
|
||||
|
|
@ -1,14 +1,33 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UpgradeBoxUI : MonoBehaviour
|
||||
public class UpgradeBoxUI : MonoBehaviour, IDropHandler
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI counterUI;
|
||||
public Image upgradeImage;
|
||||
public AbilityUpgrade thisAbilityUpgrade;
|
||||
public PlayerAbility thisPlayerAbility;
|
||||
public void UpdateCounter()
|
||||
{
|
||||
if (!thisAbilityUpgrade)
|
||||
{
|
||||
counterUI.gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
counterUI.gameObject.SetActive(true);
|
||||
counterUI.text = $"x{thisAbilityUpgrade.count}";
|
||||
}
|
||||
|
||||
public void OnDrop(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("A");
|
||||
if (eventData.pointerDrag.TryGetComponent(out StoredAbilityUpgradeUI isStoredUpgrade) && (!thisAbilityUpgrade || isStoredUpgrade.storedUpgrade == thisAbilityUpgrade))
|
||||
{
|
||||
thisAbilityUpgrade = isStoredUpgrade.storedUpgrade;
|
||||
AbilityManager.instance.AddUpgrade(thisAbilityUpgrade, thisPlayerAbility);
|
||||
UpdateCounter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue