literally half of the game

This commit is contained in:
Sylvia 2026-08-27 04:07:01 -07:00
parent 1590b5faa6
commit b842289076
77 changed files with 11904 additions and 72 deletions

View file

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

View file

@ -0,0 +1,46 @@
using System;
using Core.Extensions;
using UnityEngine;
public class Ability : MonoBehaviour
{
[Header("Flags")]
public bool cooldownBlocked;
public bool blocked;
[Header("Cooldown")]
public float cooldown;
protected float currentCooldown;
[Header("Stats")]
public float power;
public bool TryAbility()
{
if (!blocked && currentCooldown <= 0)
{
currentCooldown = cooldown;
AbilityEffects();
return true;
}
return false;
}
protected virtual void AbilityEffects()
{
}
private void Update()
{
if (currentCooldown > 0 && !cooldownBlocked)
{
currentCooldown -= Time.deltaTime;
}
}
protected void ShootBullet(Projectile projectile, Vector3 direction)
{
Projectile newProjectile = Instantiate(projectile, transform.position, Quaternion.identity);
newProjectile.transform.Lookat2D(direction);
newProjectile.tag = tag; //will have to figure out stats and projectile creation
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0057d0e1aa27e88a6922b74c1ef23cc8

View file

@ -0,0 +1,10 @@
using UnityEngine;
using UnityEngine.InputSystem.LowLevel;
public class PlayerAbility : Ability
{
[Header("Input")]
public KeyCode inputKey; //change to better input system later
public MouseButton mouseButton; //alternative input
}

View file

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

View file

@ -0,0 +1,12 @@
using UnityEngine;
public class ReisenShoot : PlayerAbility
{
[Header("Projectile")]
[SerializeField] private Projectile projectile;
protected override void AbilityEffects()
{
base.AbilityEffects();
ShootBullet(projectile, GameManager.instance.GetMouseWorldPos());
}
}

View file

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

View file

@ -6,6 +6,7 @@ public class CombatEntity : Entity
public float maxHealth;
public float health;
public bool invulnerable;
public bool isSafe;
public void TakeDamage(float damage)
{

View file

@ -2,4 +2,59 @@ using UnityEngine;
public class Enemy : CombatEntity
{
[Header("Targetting")]
public CombatEntity closestTarget; //actually get the detected target first
public bool detectedPlayer = false;
[Header("Direction")]
public Transform[] possibleDirections;
public float forwardPercent;
public float strafePercent;
public float directionVariance; //how much strafe/forward vary
protected float xSign = -1f;
protected float ySign = 1f;
private void Start()
{
if (Random.Range(0f, 2f) > 1f)
{
xSign = -xSign;
ySign = -ySign;
}
float newVariance = Random.Range(-directionVariance, directionVariance);
forwardPercent += newVariance;
strafePercent -= newVariance;
}
protected override void Movement()
{
if (stalled || !closestTarget || !detectedPlayer || closestTarget.isSafe)
{
moveDirection = Vector3.zero;
}
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;
}
}
moveDirection = directionToMove;
//FlipSprite(directionToMove);
// ^ add when you actually draw sprites
}
}
}

View file

@ -0,0 +1,15 @@
using System;
using UnityEngine;
public class EnemyDetection : MonoBehaviour
{
public Enemy thisEnemy;
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag(thisEnemy.tag) && other.TryGetComponent(out Player isPlayer))
{
thisEnemy.detectedPlayer = true;
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 75cd0318c03eac209af986e5dffde52b

View file

@ -3,11 +3,27 @@ using UnityEngine;
public class Entity : MonoBehaviour
{
[Header("Sprite")]
public SpriteRenderer sprite;
[Header("Movement")]
public float speed;
[SerializeField] protected Rigidbody2D rb;
public Vector3 moveDirection;
public bool noMovement;
public bool stalled;
public bool isFacingRight;
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 Movement()
{
@ -15,10 +31,14 @@ public class Entity : MonoBehaviour
private void FixedUpdate()
{
if (!noMovement)
if (!stalled)
{
Movement();
rb.linearVelocity = moveDirection * speed;
}
else
{
rb.linearVelocity = Vector2.zero;
}
}
}

View file

@ -2,5 +2,10 @@ using UnityEngine;
public class NPC : Entity
{
[Header("Dialogue")]
public DialogueScript dialogueToShow; //supposed to be able to have different dialogue but we'll go with this for now
public void StartDialogue()
{
DialogueManager.instance.StartDialogue(dialogueToShow);
}
}

View file

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
public class Player : CombatEntity
{
@ -11,7 +13,10 @@ public class Player : CombatEntity
{
//moveAction = InputSystem.actions.FindAction("Move");
}*/
[Header("Abilities")]
public bool abilitiesDisabled;
public List<PlayerAbility> abilities = new();
protected override void Movement()
{
base.Movement();
@ -19,4 +24,20 @@ public class Player : CombatEntity
//moveDirection = moveAction.ReadValue<Vector2>();
moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
}
private void Update()
{
foreach (PlayerAbility ability in abilities)
{
if (Input.GetKeyDown(ability.inputKey))
{
ability.TryAbility();
}
else if (ability.inputKey == KeyCode.None && Input.GetMouseButtonDown((int)ability.mouseButton))
{
//really needs to be fixed to the new input system
ability.TryAbility();
}
}
}
}

View file

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class PlayerTalkRange : MonoBehaviour
{
private List<NPC> npcsInRange = new(); //also indicate the npc you're closest to
[Header("UI")]
[SerializeField] private Transform talkPopupUI;
[SerializeField] private Vector3 uiOffset;
private void OnTriggerEnter2D(Collider2D other)
{
if (other.TryGetComponent(out NPC isNPC) && !npcsInRange.Contains(isNPC)) //placeholder key lol
{
npcsInRange.Add(isNPC);
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.TryGetComponent(out NPC isNPC) && npcsInRange.Contains(isNPC)) //placeholder key lol
{
npcsInRange.Remove(isNPC);
if (npcsInRange.Count == 0)
{
talkPopupUI.gameObject.SetActive(false);
}
}
}
private void Update()
{
if (npcsInRange.Count > 0)
{
NPC closestNPC = null;
foreach (NPC npc in npcsInRange)
{
if (!closestNPC || Vector3.Distance(closestNPC.transform.position, transform.position) >
Vector3.Distance(npc.transform.position, transform.position))
{
closestNPC = npc;
}
}
if (closestNPC)
{
if (!talkPopupUI.gameObject.activeSelf)
{
talkPopupUI.gameObject.SetActive(true);
}
talkPopupUI.position = closestNPC.transform.position + uiOffset;
}
if (DialogueManager.instance.currentDialogueScript == null && Input.GetKeyDown(KeyCode.E))
{
closestNPC.StartDialogue();
}
}
}
}

View file

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