Files
Cielonos/Assets/Scripts/MainGame/AttackArea/Submodules/LinearDirectionMoveSubmodule.cs
SoulliesOfficial f7af60351b 阶段性完成
2025-12-08 05:27:53 -05:00

43 lines
1.6 KiB
C#

using UnityEngine;
namespace Cielonos.MainGame
{
public class LinearDirectionMoveSubmodule : MoveSubmoduleBase
{
public Vector3 direction;
public float speed;
public float acceleration;
public bool disableNegative;
public LinearDirectionMoveSubmodule(AttackAreaBase attackArea, Vector3 direction, float speed, float acceleration,
bool overrideRotation, bool disableNegative, bool stopWhenHit, float timeScaleCoefficient) :
base(attackArea, stopWhenHit, timeScaleCoefficient)
{
this.direction = direction;
this.speed = speed;
this.acceleration = acceleration;
this.disableNegative = disableNegative;
this.timeScaleCoefficient = timeScaleCoefficient;
if (overrideRotation)
{
attackArea.topParent.transform.rotation = Quaternion.LookRotation(direction);
}
}
public override void Update()
{
speed += acceleration * (timeScaleCoefficient * Time.deltaTime); //attackArea.creator.selfTimeModule.EntityDeltaTime);
speed = Mathf.Max(0, speed);
if ((disableNegative && speed < 0) || !canMove)
{
speed = 0;
}
unscaledVelocity = direction * speed;
scaledVelocity = unscaledVelocity * timeScaleCoefficient; //attackArea.creator.selfTimeModule.EntityDeltaTime);
attackArea.topParent.transform.position += scaledVelocity * Time.deltaTime;
}
}
}