81 lines
1.7 KiB
C#
81 lines
1.7 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace NBF
|
|
{
|
|
public abstract class FPlayerGear : MonoBehaviour
|
|
{
|
|
private bool _isInit;
|
|
public FPlayer Owner { get; protected set; }
|
|
|
|
public FGearData GearData { get; protected set; }
|
|
|
|
|
|
public FRod Rod { get; protected set; }
|
|
|
|
public void Start()
|
|
{
|
|
// OnStart();
|
|
}
|
|
|
|
public void Initialize(FPlayer player, FGearData gearData = null)
|
|
{
|
|
Owner = player;
|
|
Rod = Owner.Gears.Rod;
|
|
GearData = gearData;
|
|
OnStart();
|
|
_isInit = true;
|
|
}
|
|
|
|
|
|
public void Update()
|
|
{
|
|
if (!_isInit) return;
|
|
if (!Owner || Owner.Data == null) return;
|
|
if (!Owner.Gears) return;
|
|
OnUpdate();
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
if (!_isInit) return;
|
|
OnFixedUpdate();
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!_isInit) return;
|
|
OnLateUpdate();
|
|
}
|
|
|
|
protected virtual void OnStart()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnUpdate()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnFixedUpdate()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnLateUpdate()
|
|
{
|
|
}
|
|
|
|
#region 工具方法
|
|
|
|
protected void CheckDistance(Transform target, float distance = 0.01f)
|
|
{
|
|
var dis = Vector3.Distance(transform.position, target.position);
|
|
if (dis > distance)
|
|
{
|
|
// transform.position = target.position;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |