2026-01-03 18:19:39 -05:00
|
|
|
|
using System;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
using SLSUtilities.General;
|
2026-01-03 18:19:39 -05:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
public partial class AuxiliaryDrone : MonoBehaviour
|
2026-01-03 18:19:39 -05:00
|
|
|
|
{
|
|
|
|
|
|
public Player player => MainGameManager.Player;
|
|
|
|
|
|
public GameObject droneModel;
|
|
|
|
|
|
public Transform center;
|
|
|
|
|
|
public Transform muzzle;
|
|
|
|
|
|
public Vector3 velocity, offset;
|
|
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
SetDroneEmissionColor(Color.cyan);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-03 18:19:39 -05:00
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
2026-06-12 17:11:39 -04:00
|
|
|
|
// selfTimeSm.TimeScale 不包含 Unity 的 Time.timeScale,
|
|
|
|
|
|
// 因此暂停时 TimeScale 可能非零但 DeltaTime 为零,需检查 DeltaTime 避免除零。
|
|
|
|
|
|
float deltaTime = player.selfTimeSm.DeltaTime;
|
|
|
|
|
|
if (deltaTime < Mathf.Epsilon)
|
2026-01-03 18:19:39 -05:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-12 17:11:39 -04:00
|
|
|
|
Vector3 moveDirection = player.landMovementSc.horizontalMovement / deltaTime;
|
2026-01-03 18:19:39 -05:00
|
|
|
|
moveDirection *= 0.1f;
|
|
|
|
|
|
|
|
|
|
|
|
Transform playerTransform = player.transform;
|
|
|
|
|
|
Vector3 cameraRight = player.viewSc.playerCamera.transform.right;
|
|
|
|
|
|
float dot = Vector3.Dot(moveDirection.normalized, cameraRight);
|
|
|
|
|
|
Vector3 realOffset = cameraRight * offset.x + playerTransform.up * offset.y;
|
|
|
|
|
|
Vector3 targetPosition = playerTransform.position + moveDirection * Mathf.Max(0, dot) + realOffset;
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 dronePosition = transform.position;
|
|
|
|
|
|
float posX = Mathf.SmoothDamp(dronePosition.x, targetPosition.x, ref velocity.x, 0.1f);
|
|
|
|
|
|
float posY = Mathf.SmoothDamp(dronePosition.y, targetPosition.y, ref velocity.y, 0.3f);
|
|
|
|
|
|
float posZ = Mathf.SmoothDamp(dronePosition.z, targetPosition.z, ref velocity.z, 0.1f);
|
|
|
|
|
|
|
|
|
|
|
|
dronePosition = new Vector3(posX, posY, posZ);
|
|
|
|
|
|
transform.position = dronePosition;
|
|
|
|
|
|
|
|
|
|
|
|
/*EnemyController availableEnemy = GameManager.enemyManager.GetIdealEnemy(float.MaxValue, true);
|
|
|
|
|
|
if (availableEnemy != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Vector3 enemyPosition = availableEnemy.flexibleCenterPoint.position;
|
|
|
|
|
|
Vector3 lookAtDirection = (enemyPosition - dronePosition).normalized;
|
|
|
|
|
|
transform.forward = Vector3.Lerp(transform.forward, lookAtDirection, 0.2f);
|
|
|
|
|
|
}
|
|
|
|
|
|
else*/
|
|
|
|
|
|
{
|
|
|
|
|
|
Vector3 lookAtDirection = player.viewSc.playerCamera.transform.forward;
|
|
|
|
|
|
transform.forward = Vector3.Lerp(transform.forward, lookAtDirection, 0.2f);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-23 08:27:50 -04:00
|
|
|
|
|
|
|
|
|
|
public partial class AuxiliaryDrone
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
|
|
|
|
|
|
private Color _currentEmissionColor;
|
|
|
|
|
|
|
|
|
|
|
|
public void SetDroneEmissionColor(Color color, float intensity = 3)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (color == _currentEmissionColor) return;
|
|
|
|
|
|
|
|
|
|
|
|
_currentEmissionColor = color * Mathf.Pow(2, intensity);
|
|
|
|
|
|
Material droneMaterial = droneModel.GetComponent<MeshRenderer>().material;
|
|
|
|
|
|
droneMaterial.SetColor(EmissionColor, _currentEmissionColor);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-03 18:19:39 -05:00
|
|
|
|
}
|