49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using Cielonos.MainGame.Characters;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame
|
|
{
|
|
public class TraceMoveSubmodule : MoveSubmoduleBase
|
|
{
|
|
public Transform projectile => owner.topParent;
|
|
public CharacterBase target;
|
|
public Transform targetTransform;
|
|
public float angularSpeed;
|
|
public float angularAcceleration;
|
|
public float moveSpeed;
|
|
public float moveAcceleration;
|
|
private Vector3 step;
|
|
|
|
public TraceMoveSubmodule(AttackAreaBase attackArea, CharacterBase target, float moveSpeed, float moveAcceleration,
|
|
float angularSpeed, float angularAcceleration, Vector3 initialDirection) : base(attackArea)
|
|
{
|
|
this.target = target;
|
|
this.targetTransform = target.transform;
|
|
this.angularSpeed = angularSpeed;
|
|
this.angularAcceleration = angularAcceleration;
|
|
this.moveSpeed = moveSpeed;
|
|
this.moveAcceleration = moveAcceleration;
|
|
projectile.forward = initialDirection;
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
if (target == null ) //|| target.isDead)
|
|
{
|
|
return;
|
|
}
|
|
|
|
angularSpeed += angularAcceleration * Time.deltaTime;
|
|
moveSpeed += moveAcceleration * Time.deltaTime;
|
|
angularSpeed = Mathf.Max(angularSpeed, 0f);
|
|
moveSpeed = Mathf.Max(moveSpeed, 0f);
|
|
|
|
projectile.rotation = Quaternion.Lerp(projectile.rotation, Quaternion.LookRotation(target.flexibleCenterPoint.position - projectile.position), Time.deltaTime * angularSpeed);
|
|
|
|
unscaledVelocity = projectile.forward * moveSpeed;
|
|
scaledVelocity = unscaledVelocity * timeScaleCoefficient; //attackArea.creator.selfTimeModule.EntityDeltaTime);
|
|
projectile.position += scaledVelocity * Time.deltaTime;
|
|
}
|
|
}
|
|
}
|