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,89 @@
using Core.Extensions;
using UnityEngine;
using System.Collections.Generic;
public class Enemy : Entity
{
[Header("Targetting")]
public Entity closestTarget;
public float engagementRange;
public bool detectedPlayer = false;
[Header("Direction")]
public float acceleration;
public Transform[] possibleDirections;
public float forwardPercent;
public float strafePercent;
private float xSign = -1f;
private float ySign = 1f;
[System.Serializable]
public class UpgradeDrop
{
public AbilityUpgrade droppedUpgrade;
public float chance;
}
[Header("Drops")]
public List<UpgradeDrop> possibleDrops = new();
private void Start()
{
if (Random.Range(0f, 2f) > 1f)
{
xSign = -xSign;
ySign = -ySign;
}
}
protected override void FixedUpdate()
{
if (!detectedPlayer && Vector3.Distance(transform.position, closestTarget.transform.position) < engagementRange)
{
detectedPlayer = true;
}
if (stalled || !closestTarget || !detectedPlayer)
{
rb.VelocityTowards(Vector2.zero.ScaleToMagnitude(speed), acceleration);
}
else
{
Vector2 directionToTarget = (closestTarget.transform.position - transform.position).normalized;
Vector2 directionToMove = directionToTarget;
float currentHighestScore = float.NegativeInfinity;
Vector2 strafeDirection = new Vector3(directionToTarget.y * ySign, directionToTarget.x * xSign);
foreach (Transform direction in possibleDirections)
{
Vector3 directionToPoint = (direction.position - transform.position).normalized;
float forwardScore = Vector3.Dot(directionToPoint, directionToTarget);
float strafeScore = Vector3.Dot(directionToPoint, strafeDirection);
float finalScore = (forwardScore * forwardPercent) + (strafeScore * strafePercent);
//Debug.Log($"Forward: {forwardScore} Strafe: {strafeScore} Final: {finalScore}");
if (finalScore > currentHighestScore)
{
//Debug.Log($"{finalScore} is higher than current score: {currentHighestScore}");
currentHighestScore = finalScore;
directionToMove = directionToPoint;
}
}
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed), acceleration);
FlipSprite(directionToMove);
}
}
protected override void OnKillEffects()
{
Destroy(gameObject);
foreach (UpgradeDrop drop in possibleDrops)
{
DropUpgrade(drop);
}
}
protected virtual void DropUpgrade(UpgradeDrop drop)
{
float random = Random.Range(0, 100);
{
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
}
}
}
}

View file

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

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
public class EnemySpawner : MonoBehaviour
{
[SerializeField] private Marisa player;
public Enemy[] enemiesToSpawn;
public List<Transform> spawnPoints;
public float spawnRate;
[SerializeField] private float currentSpawnTime;
[SerializeField] private Transform enemyFolder;
private void Update()
{
currentSpawnTime -= Time.deltaTime;
if (currentSpawnTime < 0)
{
currentSpawnTime = spawnRate;
SpawnEnemy(enemiesToSpawn[Random.Range(0, enemiesToSpawn.Length)], spawnPoints[Random.Range(0, spawnPoints.Count)].position);
}
}
public void SpawnEnemy(Enemy enemy, Vector3 location)
{
Enemy newEnemy = Instantiate(enemy, location, Quaternion.identity);
newEnemy.transform.SetParent(enemyFolder);
newEnemy.closestTarget = player; //idk if there's actually gonna be any other target lol
}
}

View file

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

View file

@ -0,0 +1,58 @@
using UnityEngine;
public class Entity : MonoBehaviour
{
[Header("Identification")]
public string entityName;
public SpriteRenderer sprite;
[Header("Flags")]
public bool stalled;
public bool invincible;
[Header("Stats")]
public float health;
public float maxHealth;
[Header("Movement")]
[SerializeField] private bool isFacingRight;
[SerializeField] protected Rigidbody2D rb;
protected Vector2 moveDirection;
public float speed;
protected void FlipSprite(Vector2 lookDirection)
{
if (lookDirection.x < 0f && isFacingRight)
{
sprite.flipX = true;
isFacingRight = !isFacingRight;
}
else if (lookDirection.x > 0f && !isFacingRight)
{
sprite.flipX = false;
isFacingRight = !isFacingRight;
}
}
protected virtual void FixedUpdate()
{
if (!stalled)
{
rb.linearVelocity = moveDirection * speed;
}
}
public void TakeDamage(float damage)
{
health -= damage;
if (health < 0)
{
OnKillEffects();
}
}
public void Heal(float healingAmount)
{
health += healingAmount;
health = Mathf.Clamp(health, 0, maxHealth);
}
protected virtual void OnKillEffects()
{
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 74fafccf721a0a5d2b3580fb7042d4f8

View file

@ -0,0 +1,23 @@
using System;
using Core.Extensions;
using UnityEngine;
public class Marisa : Entity
{
[Header("Mouse")]
[SerializeField] private Camera cam;
public Vector2 mouseWorldPos;
public Transform firingPointBase;
public Transform firingPoint;
private void Update()
{
mouseWorldPos = cam.ScreenToWorldPoint(Input.mousePosition);
firingPointBase.Lookat2D(mouseWorldPos);
}
protected override void FixedUpdate()
{
moveDirection = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
base.FixedUpdate();
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 52bda12b42435d197a10a340f8608249

View file

@ -0,0 +1,52 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class MarisaAbilityHandler : MonoBehaviour
{
[SerializeField] private PlayerInput inputHandler;
[SerializeField] private Marisa thisPlayer;
[Header("Abilities")] //maybe have to make them public for when you're changing out abilities
[SerializeField] private PlayerAbility mainAttack;
[SerializeField] private PlayerAbility secondaryAttack;
[SerializeField] private PlayerAbility spellA;
[SerializeField] private PlayerAbility spellB;
[Header("Ability Instances")]
public PlayerAbility mainAttackInstance;
public PlayerAbility secondaryAttackInstance;
public PlayerAbility spellAInstance;
public PlayerAbility spellBInstance;
private void Awake()
{
mainAttackInstance = Instantiate(mainAttack, transform);
mainAttackInstance.thisPlayer = thisPlayer;
secondaryAttackInstance = Instantiate(secondaryAttack, transform);
secondaryAttackInstance.thisPlayer = thisPlayer;
spellAInstance = Instantiate(spellA, transform);
spellAInstance.thisPlayer = thisPlayer;
spellBInstance = Instantiate(spellB, transform);
spellBInstance.thisPlayer = thisPlayer;
}
private void Update()
{
if (inputHandler.actions["MainAttack"].inProgress)
{
mainAttackInstance.TryAbility();
}
else if (inputHandler.actions["SecondaryAttack"].inProgress)
{
secondaryAttackInstance.TryAbility();
}
else if (inputHandler.actions["SpellA"].inProgress)
{
spellAInstance.TryAbility();
}
else if (inputHandler.actions["SpellB"].inProgress)
{
spellBInstance.TryAbility();
}
}
}

View file

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