well it works

This commit is contained in:
reisenlol 2026-01-11 21:27:27 -08:00
parent 6ff1531662
commit af9b1a7448
No known key found for this signature in database
11 changed files with 563 additions and 13 deletions

View file

@ -17,7 +17,7 @@ public class Entity : MonoBehaviour
public bool canMove = true;
public bool invincible;
public void TakeDamage(float damage)
public virtual void TakeDamage(float damage)
{
health -= damage;
if (health <= 0)

View file

@ -3,12 +3,15 @@ using UnityEngine;
public class PlayerEntity : Entity
{
[Header("Player Flags")]
public bool hasMoved = false;
public bool hasAttacked = false;
private List<TileObject> moveableTiles = new();
[Header("Weaponry")]
[SerializeField] private Weapon[] weapons;
private List<Weapon> weaponInstances = new();
public Weapon currentWeapon;
[Header("UI")]
[SerializeField] private Transform hpBar;
void Start()
{
foreach (Weapon weapon in weapons)
@ -27,6 +30,16 @@ public class PlayerEntity : Entity
}
public override void TakeDamage(float amount)
{
base.TakeDamage(amount);
UpdateHealthUI();
}
public void UpdateHealthUI()
{
hpBar.localScale = new Vector3(health/maxHealth, 1f, 1f);
}
public void SkipTurn()
{
hasMoved = true;

View file

@ -66,7 +66,7 @@ public class PlayerEntityMovement : MonoBehaviour
requestedTile = newTile;
foreach (TileObject tile in pathRequested)
{
tile.sprite.color = new Color(137,137,137);
tile.sprite.color = new Color(137, 137, 137, 255);
}
PathfindToTarget();
}
@ -98,7 +98,7 @@ public class PlayerEntityMovement : MonoBehaviour
{
foreach (TileObject tileObject in currentMovableTiles)
{
tileObject.sprite.color = new Color(137,137,137);
tileObject.sprite.color = new Color32(137,137,137, 255);
}
}

View file

@ -10,6 +10,13 @@ public class Projectile : MonoBehaviour
public float speed;
public int pierceAmount;
private int currentPierce;
public float destructionTime;
private void Start()
{
Destroy(gameObject, destructionTime);
}
private void FixedUpdate()
{
rb.linearVelocity = transform.right * speed;
@ -32,4 +39,9 @@ public class Projectile : MonoBehaviour
}
}
}
private void OnDestroy()
{
TurnHandler.instance.UpdateTurns();
}
}

View file

@ -41,7 +41,6 @@ public class RangedWeapon : Weapon
fired = true;
isAiming = false;
thisEntity.hasAttacked = true;
TurnHandler.instance.UpdateTurns();
}
else if (Input.GetMouseButtonDown(1))
{

View file

@ -53,13 +53,13 @@ public class TurnHandler : MonoBehaviour
return;
}
}
currentGameState = GameState.EnemyTurn;
if (!enemyEntities[0])
if (enemyEntities.Count == 0)
{
EndRound();
}
else
{
currentGameState = GameState.EnemyTurn;
enemyEntities[0].StartTurn();
}
}