more abilities and fixes
This commit is contained in:
parent
cb4470f2d6
commit
fc2329a873
31 changed files with 268 additions and 52 deletions
29
Assets/Scripts/Entities/Enemy.cs
Normal file
29
Assets/Scripts/Entities/Enemy.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Enemy : AutoControlledEntity
|
||||
{
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!stats.isStalled)
|
||||
{
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange)
|
||||
{
|
||||
direction.x = (closestEntity.transform.position - transform.position).normalized.x * stats.speed;
|
||||
if ((closestEntity.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(closestEntity.transform.position, transform.position) > minTargetJumpDistance)) && stats.OnGround())
|
||||
{
|
||||
direction.y = stats.jumpPower;
|
||||
}
|
||||
}
|
||||
FlipSprite(direction);
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDeath()
|
||||
{
|
||||
base.OnDeath();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue