random stuff i forgot to commit

This commit is contained in:
Sylvia 2026-06-26 14:37:33 -07:00
parent 274af1e5a1
commit b0625ae834
59 changed files with 7806 additions and 664 deletions

View file

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

View file

@ -29,7 +29,7 @@ public class Ability : MonoBehaviour
}
private void Update()
protected virtual void Update()
{
if (currentCooldown >= 0)
{

View file

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Random = UnityEngine.Random;
public class YoumuDeflect : Ability
{
private List<Projectile> projectilesInRange = new();
public float deflectionAngleMin = -48;
public float deflectionAngleMax = 90;
[Header("Effects")]
[SerializeField] private ParticleSystem deflectionParticles;
[SerializeField] private GameObject swordSweepEffect;
private float currentDissipationTime = 0f;
[SerializeField] private float dissipationTime;
protected override void AbilityEffects()
{
base.AbilityEffects();
swordSweepEffect.gameObject.SetActive(true);
currentDissipationTime = dissipationTime;
foreach (Projectile projectile in projectilesInRange.ToList())
{
if (!projectile)
{
projectilesInRange.Remove(projectile);
continue;
}
projectile.transform.eulerAngles = new Vector3(0, 0, Random.Range(deflectionAngleMin, deflectionAngleMax));
projectile.direction = projectile.transform.right;
projectile.tag = tag;
ParticleSystem newParticles = Instantiate(deflectionParticles, projectile.transform);
projectilesInRange.Remove(projectile);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile))
{
projectilesInRange.Add(isProjectile);
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
{
projectilesInRange.Add(isProjectile);
}
}
protected override void Update()
{
base.Update();
if (currentDissipationTime > 0)
{
currentDissipationTime -= Time.deltaTime;
if (currentDissipationTime <= 0)
{
swordSweepEffect.SetActive(false);
}
}
}
}

View file

@ -0,0 +1,16 @@
using UnityEngine;
public class DialogueManager : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View file

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

View file

@ -1,19 +0,0 @@
using System;
using UnityEngine;
public class Enemy : Entity
{
private void Update()
{
foreach (Ability ability in abilities)
{
ability.TryAbility();
}
}
protected override void OnDeath()
{
base.OnDeath();
Destroy(gameObject);
}
}

View file

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

View file

@ -0,0 +1,69 @@
using System;
using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
public class Enemy : Entity
{
public SpriteRenderer sprite;
private float currentState = 1;
public float colorChangeSpeed;
[Header("Movement")]
private float currentMovement;
public float moveSpeed;
public float moveSpeedDelta;
private void Start()
{
moveSpeed += Random.Range(-moveSpeedDelta, moveSpeedDelta);
}
private void Update()
{
if (!isStalled)
{
foreach (Ability ability in abilities)
{
ability.direction = WaveManager.instance.GetRandomPlayerPoint();
bool success = ability.TryAbility();
if (!success && ability.currentCooldown <= 0.5f && currentState >= 1f)
{
currentState = 0f;
StartCoroutine(ImminentAttackAnim());
}
}
}
}
protected override void OnDeath()
{
base.OnDeath();
Destroy(gameObject);
WaveManager.instance.enemiesInPlay.Remove(this);
WaveManager.instance.UpdateKills();
}
private IEnumerator ImminentAttackAnim()
{
while (currentState < 1)
{
currentState += Time.deltaTime * colorChangeSpeed;
sprite.color = Color.Lerp(Color.red, Color.white, currentState);
yield return null;
}
}
public IEnumerator MoveToPosition(Vector3 moveDirection)
{
while (currentMovement < 1)
{
currentMovement += Time.deltaTime * moveSpeed;
if (currentMovement >= 1)
{
isStalled = false;
}
transform.position = Vector3.Lerp(WaveManager.instance.enemySpawnPoint.position, moveDirection, currentMovement);
yield return null;
}
}
}

View file

@ -13,7 +13,7 @@ public class Entity : MonoBehaviour
[Header("Abilities")]
public List<Ability> abilities = new();
public void TakeDamage(int damage)
public virtual void TakeDamage(int damage)
{
health -= damage;
if (health <= 0)

View file

@ -1,9 +1,12 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class Player : Entity
{
void Update()
[Header("UI")]
[SerializeField] private TextMeshProUGUI livesText;
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
@ -14,4 +17,14 @@ public class Player : Entity
abilities[1].TryAbility();
}
}
public override void TakeDamage(int damage)
{
base.TakeDamage(damage);
UpdateLivesUI();
}
private void UpdateLivesUI()
{
livesText.text = $"Lives: {health}/{maxHealth}";
}
}

View file

@ -0,0 +1,22 @@
using System;
using UnityEngine;
public class GetPixelSize : MonoBehaviour
{
private void Start()
{
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
Bounds bounds = spriteRenderer.bounds; // World-space boundary box
// Convert the minimum and maximum world space corners to screen pixel positions
Vector3 minScreenPos = Camera.main.WorldToScreenPoint(bounds.min);
Vector3 maxScreenPos = Camera.main.WorldToScreenPoint(bounds.max);
// Calculate the actual screen pixel delta
float screenPixelWidth = maxScreenPos.x - minScreenPos.x;
float screenPixelHeight = maxScreenPos.y - minScreenPos.y;
Debug.Log($"Name: {gameObject.name}Actual Screen Size: {screenPixelWidth}x{screenPixelHeight} physical pixels");
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 21593cfdc58bdd807a3d6a0ddf5ed225

View file

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

View file

@ -1,3 +1,4 @@
using System;
using UnityEngine;
public class Projectile : MonoBehaviour

View file

@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using Random = UnityEngine.Random;
public class WaveManager : MonoBehaviour
{
#region Statication
public static WaveManager instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
}
#endregion
[System.Serializable]
public class Wave
{
public Enemy[] enemies;
}
[Header("Player Point")]
[SerializeField] private Transform tlPoint;
[SerializeField] private Transform brPoint;
[Header("Enemy Point")]
[SerializeField] private Transform enemyTLPoint;
[SerializeField] private Transform enemyBRPoint;
public Transform enemySpawnPoint;
[Header("Waves")]
[SerializeField] private TextMeshProUGUI waveUI;
public int wave = 1;
public Wave[] waveList;
[Header("Enemies")]
public Transform enemyFolder;
public List<Enemy> enemiesInPlay = new();
[SerializeField] private float enemyCheckRadius;
[SerializeField] private LayerMask enemyLayer;
private void Start()
{
SpawnWave();
}
public Vector3 GetRandomPlayerPoint()
{
return new Vector3(Random.Range(tlPoint.position.x, brPoint.position.x),
Random.Range(brPoint.position.y, tlPoint.position.y), 0);
}
private Vector3 GetRandomEnemyPoint()
{
Vector3 randomPoint;
do
{
randomPoint = new Vector3(Random.Range(enemyTLPoint.position.x, enemyBRPoint.position.x),
Random.Range(enemyBRPoint.position.y, enemyTLPoint.position.y), 0);
} while (CheckEnemyOverlap(randomPoint));
return randomPoint;
}
private bool CheckEnemyOverlap(Vector3 areaToCheck)
{
if (Physics2D.OverlapCircle(areaToCheck, enemyCheckRadius, enemyLayer))
{
return true;
}
return false;
}
private void SpawnWave()
{
waveUI.text = $"Wave: {wave}";
foreach (Enemy enemy in waveList[wave-1].enemies)
{
Enemy newEnemy = Instantiate(enemy, enemyFolder);
newEnemy.StartCoroutine(newEnemy.MoveToPosition(GetRandomEnemyPoint()));
enemiesInPlay.Add(newEnemy);
newEnemy.isStalled = true;
}
wave++;
}
public void UpdateKills()
{
if (enemiesInPlay.Count == 0)
{
SpawnWave();
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7efbe47d2619e84c5a8c30f4f0a622d4

View file

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class YoumuDeflect : Ability
{
private List<Projectile> projectilesInRange = new();
protected override void AbilityEffects()
{
base.AbilityEffects();
foreach (Projectile projectile in projectilesInRange)
{
projectile.transform.eulerAngles = new Vector3(0, 0, 180);
projectile.direction = -transform.right;
projectile.tag = tag;
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile))
{
projectilesInRange.Add(isProjectile);
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
{
projectilesInRange.Add(isProjectile);
}
}
}