implementing goblin death, need to find way deactivate it for time
This commit is contained in:
+37
-18
@@ -1,11 +1,15 @@
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyAI : Character
|
||||
{
|
||||
private bool _needRespawn = false;
|
||||
private int _respawnTimeout = 4;
|
||||
private float _respawnElementTimer;
|
||||
|
||||
protected override void OnDeath()
|
||||
{
|
||||
}
|
||||
_needRespawn = true;
|
||||
}
|
||||
|
||||
protected override void SetClimbingAnimation(bool isClimbing)
|
||||
{
|
||||
@@ -17,35 +21,50 @@ public class EnemyAI : Character
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(_needRespawn)
|
||||
{
|
||||
_respawnElementTimer -= Time.deltaTime;
|
||||
if (_respawnElementTimer <= 0)
|
||||
{
|
||||
_respawnElementTimer = _respawnTimeout;
|
||||
_needRespawn = false;
|
||||
Spawn();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
float horizontal = 0;
|
||||
float vertical = 0;
|
||||
|
||||
Vector2 directionToPlayer = Player.Instance.transform.position - transform.position;
|
||||
Vector2 directionToPlayer = Player.Instance.transform.position - transform.position;
|
||||
directionToPlayer.Normalize();
|
||||
|
||||
float verticalDistance = Player.Instance.transform.position.y - transform.position.y;
|
||||
|
||||
if (Mathf.Abs(Player.Instance.transform.position.y - transform.position.y) < 0.1f)
|
||||
|
||||
if (verticalDistance > 0 && isCanClimbUp && isAllowVertical)
|
||||
{
|
||||
horizontal = directionToPlayer.x;
|
||||
vertical = VerticalMove(verticalDistance);
|
||||
}
|
||||
else if (verticalDistance>0 && isCanClimbUp && isAllowVertical)
|
||||
else if (verticalDistance < 0 && isAllowVertical && isCanGoDown)
|
||||
{
|
||||
vertical =VerticalMove(verticalDistance);
|
||||
}
|
||||
else if (verticalDistance<0 && isAllowVertical)
|
||||
{
|
||||
vertical =VerticalMove(verticalDistance);
|
||||
vertical = VerticalMove(verticalDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
horizontal = directionToPlayer.x;
|
||||
}
|
||||
if (Mathf.Abs(Player.Instance.transform.position.x - transform.position.x) < 0.1f)
|
||||
{
|
||||
print($"horizontal block");
|
||||
horizontal = 0;
|
||||
}
|
||||
else if (directionToPlayer.x < 0)
|
||||
{ horizontal = -1; }
|
||||
else if (directionToPlayer.x > 0)
|
||||
{ horizontal = 1; }
|
||||
|
||||
}
|
||||
print($"horizontal {horizontal}");
|
||||
|
||||
if (Input.GetKey(KeyCode.F))
|
||||
{ horizontal = -1; }
|
||||
if (Input.GetKey(KeyCode.H))
|
||||
{ horizontal = 1; }
|
||||
if (Input.GetKey(KeyCode.T))
|
||||
{ vertical = 1; }
|
||||
if (Input.GetKey(KeyCode.G))
|
||||
|
||||
Reference in New Issue
Block a user