feat: Phase 1 complete - attack system, enemy damage, timers, and study notes summary

This commit is contained in:
2026-05-27 10:42:39 +08:00
parent c2b93486c5
commit 18394a6b46
18 changed files with 1885 additions and 56 deletions

42
Assets/Enemy.cs Normal file
View File

@@ -0,0 +1,42 @@
using UnityEngine;
public class Enemy : MonoBehaviour
{
private SpriteRenderer sr;
[SerializeField]private float redColorDuration = 1;
public float currentTimeInGame;
public float lastTimeWasDamaged;
private void Awake()
{
sr = GetComponent<SpriteRenderer>();
}
private void Update()
{
ChanceColorIfNeedes();
}
private void ChanceColorIfNeedes()
{
currentTimeInGame = Time.time;
if (currentTimeInGame > lastTimeWasDamaged + redColorDuration)
{
if (sr.color != Color.white)
{
TurnWhite();
}
}
}
public void TakeDamage()
{
sr.color = Color.red;
lastTimeWasDamaged = Time.time;
}
private void TurnWhite()
{
sr.color = Color.white;
}
}