added character spawner script, spawn and destroy characters

This commit is contained in:
2023-08-01 15:48:00 +00:00
parent ef90dd7872
commit ef2b90b8b7
9 changed files with 306 additions and 660 deletions
-25
View File
@@ -2,16 +2,6 @@
public class EnemyAI : Character
{
private bool _needRespawn = false;
private int _respawnTimeout = 4;
private float _respawnElementTimer;
protected override void OnDeath()
{
_needRespawn = true;
_spriteRenderer.enabled =false;
}
protected override void SetClimbingAnimation(bool isClimbing)
{
}
@@ -22,19 +12,6 @@ public class EnemyAI : Character
private void Update()
{
if(_needRespawn)
{
_respawnElementTimer -= Time.deltaTime;
if (_respawnElementTimer <= 0)
{
_respawnElementTimer = _respawnTimeout;
_needRespawn = false;
_spriteRenderer.enabled =true;
Spawn();
}
return;
}
float horizontal = 0;
float vertical = 0;
@@ -56,7 +33,6 @@ public class EnemyAI : Character
{
if (Mathf.Abs(Player.Instance.transform.position.x - transform.position.x) < 0.1f)
{
print($"horizontal block");
horizontal = 0;
}
else if (directionToPlayer.x < 0)
@@ -65,7 +41,6 @@ public class EnemyAI : Character
{ horizontal = 1; }
}
print($"horizontal {horizontal}");
if (Input.GetKey(KeyCode.T))
{ vertical = 1; }