you really gotta calm down, marisa...

This commit is contained in:
Sylvia 2026-02-13 00:21:59 -08:00
parent 13bb58ea03
commit b9fb490dce
68 changed files with 990 additions and 44 deletions

View file

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AbilityManager : MonoBehaviour
{
#region Statication
public static AbilityManager instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
}
#endregion
public class StoredUpgrade
{
public AbilityUpgrade upgrade;
public int count;
}
public MarisaAbilityHandler player;
public AbilityUpgrade upgradeToAdd;
public Button upgradeButton;
[Header("Upgrades")]
public List<StoredUpgrade> upgradesInventory;
private void Start()
{
upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
}
public void AddUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
{
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();
}
}
}
public void RemoveUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
{
if (ability.attachedUpgrades.TryGetValue(upgrade, out AbilityUpgrade foundUpgrade))
{
if (foundUpgrade.count > 1)
{
foundUpgrade.ApplyRemoval();
foundUpgrade.count--;
}
else
{
foundUpgrade.ApplyRemoval();
ability.attachedUpgrades.Remove(foundUpgrade);
}
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1536116e866f6604e8d93d80bb9a6237

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class AbilityUIHandler : MonoBehaviour
{
public List<AbilityUIObject> uiObjects = new();
[SerializeField] private MarisaAbilityHandler playerAbilityHandler;
private void Start()
{
uiObjects[0].thisAbility = playerAbilityHandler.mainAttackInstance;
uiObjects[1].thisAbility = playerAbilityHandler.secondaryAttackInstance;
uiObjects[2].thisAbility = playerAbilityHandler.spellAInstance;
uiObjects[3].thisAbility = playerAbilityHandler.spellBInstance;
foreach (AbilityUIObject uiObject in uiObjects)
{
uiObject.UpdateUI();
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e7a1d413a4177c296860fb5599a53a0b

View file

@ -0,0 +1,52 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AbilityUIObject : MonoBehaviour
{
[Header("Ability Identification")]
[SerializeField] private Image abilityIcon;
[SerializeField] private TextMeshProUGUI abilityName;
[Header("Ability Stats")]
[SerializeField] private TextMeshProUGUI damage;
[SerializeField] private TextMeshProUGUI fireRate;
[SerializeField] private TextMeshProUGUI piercing;
[SerializeField] private TextMeshProUGUI projectileCount;
[Header("Upgrades")]
[SerializeField] private UpgradeBoxUI templateUpgradeBox;
[SerializeField] private Transform upgradeGrid;
[SerializeField] private List<UpgradeBoxUI> upgradeBoxes = new();
public PlayerAbility thisAbility;
public void UpdateUI()
{
abilityIcon.sprite = thisAbility.abilityIcon;
abilityName.text = thisAbility.abilityName;
damage.text = $"Damage: {thisAbility.power}";
fireRate.text = $"Fire rate: {thisAbility.cooldown}s";
if (thisAbility.TryGetComponent(out FireBullet isBullet))
{
piercing.text = $"Piercing: {isBullet.pierceAmount}";
projectileCount.text = $"Projectiles: {isBullet.projectileCount}";
}
}
public void AddUpgradeBox(AbilityUpgrade upgrade)
{
UpgradeBoxUI newBox = Instantiate(templateUpgradeBox, upgradeGrid);
upgradeBoxes.Add(newBox);
newBox.upgradeImage.sprite = upgrade.upgradeIcon;
newBox.UpdateCounter();
}
public void UpdateUpgradeBoxes()
{
foreach (UpgradeBoxUI box in upgradeBoxes)
{
box.UpdateCounter();
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a75a4c92b7f4707cb82c77fef57ae2b3

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fe5e49884c882fcd5b60c9d30927a02f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,23 @@
using System;
using UnityEngine;
public class BeamCollider : MonoBehaviour
{
public Laser thisLaser;
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag(thisLaser.thisPlayer.tag) && other.TryGetComponent(out Entity isEntity))
{
thisLaser.enemyList.Add(isEntity);
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (!other.CompareTag(thisLaser.thisPlayer.tag) && other.TryGetComponent(out Entity isEntity) && thisLaser.enemyList.Contains(isEntity))
{
thisLaser.enemyList.Remove(isEntity);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fa1b7388657a56c7a91ace02c52cd5ee

View file

@ -0,0 +1,36 @@
using UnityEngine;
public class FireBullet : PlayerAbility
{
[Header("Projectile Stats")]
public int pierceAmount;
public float accuracy;
public float bulletLifetime;
public float projectileSpeed;
public enum FireMode {Angled, Offset};
[Header("Projectile")]
public FireMode fireMode = FireMode.Offset;
public Vector2 offset;
public float angle;
[SerializeField] private Projectile projectile;
protected override void AbilityEffects()
{
for (int i = 0; i < projectileCount; i++)
{
Projectile newProjectile = Instantiate(projectile, thisPlayer.firingPointBase.position, transform.rotation);
newProjectile.RotateToTarget(thisPlayer.firingPoint.position);
newProjectile.transform.position = thisPlayer.firingPoint.position; //me when i set the position 3 times in a row. but it's to prevent the bullets firing behind marisa
if (fireMode == FireMode.Offset && projectileCount > 1)
{
newProjectile.transform.position += new Vector3(Random.Range(-offset.x, offset.x), Random.Range(-offset.y, offset.y));
}
newProjectile.pierceAmount = pierceAmount;
newProjectile.damage = power;
newProjectile.speed = projectileSpeed;
newProjectile.lifetime = bulletLifetime;
newProjectile.transform.Rotate(0, 0, Random.Range(-accuracy, accuracy));
newProjectile.tag = thisPlayer.tag;
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 62c2c7dce05d07c06b237843ff48ab2e

View file

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using Core.Extensions;
using UnityEngine;
public class Laser : PlayerAbility
{
[Header("Laser Properties")]
public float length;
public float width;
public float duration;
protected float currentDuration;
[Header("Beam")]
[SerializeField] protected BeamCollider beamObject;
private BeamCollider beamObjectInstance;
public float turnSpeed;
public float offset;
[Header("Weapon Properties")]
[HideInInspector] public List<Entity> enemyList = new();
public float damageDebounceTime;
protected float currentDebounce;
private void Start()
{
CreateBeam();
}
protected override void AbilityEffects()
{
canCooldown = false;
currentDuration = duration;
currentDebounce = damageDebounceTime;
beamObjectInstance.gameObject.SetActive(true);
transform.Lookat2D(thisPlayer.mouseWorldPos);
}
protected override void Update()
{
base.Update();
if (currentDuration > 0)
{
Vector3 direction = (thisPlayer.mouseWorldPos - (Vector2)transform.position).normalized;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.RotateTowards(beamObjectInstance.transform.rotation, Quaternion.Euler(0,0,angle), turnSpeed * Time.deltaTime);
currentDuration -= Time.deltaTime;
if (currentDebounce > 0)
{
currentDebounce -= Time.deltaTime;
if (currentDebounce <= 0)
{
foreach (Entity enemy in enemyList.ToArray())
{
if (!enemy)
{
enemyList.Remove(enemy);
continue;
}
enemy.TakeDamage(power);
}
currentDebounce = damageDebounceTime;
}
}
if (currentDuration <= 0)
{
canCooldown = true;
beamObjectInstance.gameObject.SetActive(false);
}
}
}
protected virtual void CreateBeam()
{
beamObjectInstance = Instantiate(beamObject, transform.position, Quaternion.identity);
beamObjectInstance.transform.SetParent(transform);
beamObjectInstance.transform.localScale = new Vector3(length, width, 1);
beamObjectInstance.transform.Translate(Vector3.right * (beamObjectInstance.transform.localScale.x * 0.5f) + new Vector3(offset, 0, 0));
beamObjectInstance.thisLaser = this;
beamObjectInstance.gameObject.SetActive(false);
}
//maybe we should've made this a projectile instead of an ability lol
//its ok we can work with this still
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d0cf7f93f057ff904b45c1d01f3de323

View file

@ -0,0 +1,66 @@
using System.Collections.Generic;
using UnityEngine;
public class NondirectionalLaser : Laser
{
[SerializeField] private int beamCount = 1;
[SerializeField] private Transform beamRoot;
private List<BeamCollider> beamInstances = new();
protected override void AbilityEffects()
{
canCooldown = false;
currentDuration = duration;
currentDebounce = damageDebounceTime;
beamRoot.gameObject.SetActive(true);
}
protected override void Update()
{
//we're doing this the stupid way i guess because i am stupid
if (currentCooldown > 0)
{
currentCooldown -= Time.deltaTime;
}
if (currentDuration > 0)
{
// i think i can just put spinobject in it and that'll work lol
if (currentDebounce > 0)
{
currentDebounce -= Time.deltaTime;
if (currentDebounce <= 0)
{
foreach (Entity enemy in enemyList.ToArray())
{
if (!enemy)
{
enemyList.Remove(enemy);
continue;
}
enemy.TakeDamage(power);
}
currentDebounce = damageDebounceTime;
}
}
if (currentDuration <= 0)
{
canCooldown = true;
beamRoot.gameObject.SetActive(false);
}
}
}
protected override void CreateBeam()
{
float rotationAmount = 360f / beamCount;
for (int i = 0; i < beamCount; i++)
{
BeamCollider newBeamObjectInstance = Instantiate(beamObject, transform.position, Quaternion.identity);
beamInstances.Add(newBeamObjectInstance);
newBeamObjectInstance.transform.SetParent(beamRoot);
newBeamObjectInstance.transform.localScale = new Vector3(length, width, 1);
newBeamObjectInstance.transform.Translate(Vector3.right * (newBeamObjectInstance.transform.localScale.x * 0.5f) + new Vector3(offset, 0, 0));
newBeamObjectInstance.transform.RotateAround(beamRoot.position, Vector3.forward, rotationAmount * i);
newBeamObjectInstance.thisLaser = this;
}
beamRoot.gameObject.SetActive(false);
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b2d9c1454ecf94f459c14e302b316986

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAbility : MonoBehaviour
{
[Header("Identification")]
public string abilityName;
public Sprite abilityIcon;
public Marisa thisPlayer;
[Header("Cooldown")]
public bool canCooldown = true;
public float cooldown;
protected float currentCooldown;
[Header("Stats")]
public float power;
public float projectileCount;
public HashSet<AbilityUpgrade> attachedUpgrades = new();
public void TryAbility()
{
if (currentCooldown <= 0 && canCooldown)
{
currentCooldown = cooldown;
AbilityEffects();
}
}
protected virtual void AbilityEffects()
{
}
protected virtual void Update()
{
if (currentCooldown > 0)
{
currentCooldown -= Time.deltaTime;
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f5c5f92fbdbe28abb8404bf5c5d1977b

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d560cfe20a1ec7b0581a0390c4d45434
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
using UnityEngine;
public class AbilityUpgrade : ScriptableObject
{
[Header("Identification")]
public string upgradeName;
public Sprite upgradeIcon;
public PlayerAbility thisPlayerAbility;
[Header("Stats")]
public int count = 1;
public virtual void ApplyUpgrade()
{
UpgradeEffects();
}
protected virtual void UpgradeEffects()
{
}
public virtual void ApplyRemoval()
{
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1d4bef84914cd439da6e7fa4a07ae966

View file

@ -0,0 +1,12 @@
using UnityEngine;
public class AttackSpeedUpgrade : AbilityUpgrade
{
[SerializeField] private float speedUpgradeAmount;
public override void ApplyUpgrade()
{
base.ApplyUpgrade();
thisPlayerAbility.cooldown *= speedUpgradeAmount;
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8cf716a335ed64e9c9c64a9e934acbd8

View file

@ -0,0 +1,10 @@
using UnityEngine;
[CreateAssetMenu(fileName = "Projectile Count Upgrade", menuName = "AbilityUpgrades/ProjectileCountUpgrade")]
public class ProjectileCountUpgrade : AbilityUpgrade
{
protected override void UpgradeEffects()
{
thisPlayerAbility.projectileCount++; //idk how this will work for the stacking.
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: abe88be260cd4b175b742754eaee097f

View file

@ -0,0 +1,14 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UpgradeBoxUI : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI counterUI;
public Image upgradeImage;
public AbilityUpgrade thisAbilityUpgrade;
public void UpdateCounter()
{
counterUI.text = $"x{thisAbilityUpgrade.count}";
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b89f179fefb96497c879d4a8dd635717

View file

@ -0,0 +1,10 @@
using UnityEngine;
public class UpgradePickup : ItemPickup
{
public AbilityUpgrade upgradeDropped;
protected override void PickupEffects()
{
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 414126e6ddc5f8085af89e294a8deb38