moved stuff to a different entity script
This commit is contained in:
parent
f4344c4700
commit
a0bfc600ef
14 changed files with 497 additions and 189 deletions
|
|
@ -1,30 +1,42 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class AutomatedPlayer : AutoControlledEntity
|
||||
{
|
||||
|
||||
public Player player;
|
||||
public float playerMinDistance;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (closestEntity)
|
||||
{
|
||||
stats.attackOriginCenter.Lookat2D(closestEntity.transform.position);
|
||||
foreach (Ability ability in stats.abilities)
|
||||
{
|
||||
ability.TryAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 direction = new Vector2(0, rb.linearVelocityY);
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
Entity target = player;
|
||||
if (!closestEntity && Vector3.Distance(player.transform.position, transform.position) <= playerMinDistance)
|
||||
{
|
||||
rb.linearVelocity = direction; //repeated code sucks but it works in this case i guess
|
||||
stats.rb.linearVelocity = direction; //repeated code sucks but it works in this case i guess
|
||||
return; //do not bother running any more code lol you're already next to the player and no enemies nearby
|
||||
}
|
||||
if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange)
|
||||
{
|
||||
target = closestEntity;
|
||||
}
|
||||
direction.x = (target.transform.position - transform.position).normalized.x * speed;
|
||||
if ((target.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)) && OnGround())
|
||||
direction.x = (target.transform.position - transform.position).normalized.x * stats.speed;
|
||||
if ((target.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)) && stats.OnGround())
|
||||
{
|
||||
direction.y = jumpPower;
|
||||
direction.y = stats.jumpPower;
|
||||
}
|
||||
rb.linearVelocity = direction;
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue