Files
Cielonos/Assets/Scripts/MainGame/AttackArea/Submodules/LinearDirectionMoveSubmodule.cs
SoulliesOfficial 39b43680a9 爆更
2026-07-18 03:16:20 -04:00

52 lines
1.8 KiB
C#

using Cielonos.MainGame.Characters;
using UnityEngine;
namespace Cielonos.MainGame
{
public partial class AttackAreaBase
{
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()
{
if (!canMove) return;
speed += acceleration * (timeScaleCoefficient * attackArea.DeltaTime);
//speed = Mathf.Max(0, speed);
if (disableNegative && speed < 0)
{
speed = 0;
}
float projectileSpeedMultiplier = attackArea.creator.attributeSm[CharacterAttribute.ProjectileSpeedMultiplier];
unscaledVelocity = direction * (speed * projectileSpeedMultiplier);
scaledVelocity = unscaledVelocity * timeScaleCoefficient;
attackArea.topParent.transform.position += scaledVelocity * attackArea.DeltaTime;
}
}
}
}