船相关脚本呢
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -4372,6 +4372,8 @@ MonoBehaviour:
|
||||
LureTrajectorySimulator: {fileID: 0}
|
||||
Light: {fileID: 4424852676135480966}
|
||||
BackSpine: {fileID: 2935101413777606001}
|
||||
Collider: {fileID: 8570688911153839359}
|
||||
Rigidbody: {fileID: 3149647016773794308}
|
||||
--- !u!114 &8072573713298176091
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -25,12 +25,6 @@ namespace NBF
|
||||
new(0.6626424f, 0.1791001f, 0.8680198f, 0.8680198f), new(1, 1, 3.38758f, 3.38758f)
|
||||
});
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 使用中
|
||||
/// </summary>
|
||||
public bool IsUse;
|
||||
|
||||
/// <summary>
|
||||
/// 船站立位置
|
||||
/// </summary>
|
||||
@@ -40,22 +34,23 @@ namespace NBF
|
||||
/// 浮力组件
|
||||
/// </summary>
|
||||
private FloatingObject _floatingObject;
|
||||
|
||||
|
||||
private float _BuoyancyFactor = 1f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_floatingObject == null) _floatingObject = GetComponent<FloatingObject>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
|
||||
public void BoatInput(Vector2 moveInput)
|
||||
{
|
||||
if (!IsUse) return;
|
||||
if (!_floatingObject.InWater) return;
|
||||
|
||||
|
||||
var input = Vector3.zero;
|
||||
Vector2 moveInput = InputManager.GetMovementInput();
|
||||
input.x = moveInput.x; // 水平转向(x轴)
|
||||
input.z = moveInput.y; // 前后移动(y轴映射到z轴)
|
||||
|
||||
var rb = _floatingObject.RigidBody;
|
||||
|
||||
// Thrust
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace NBF
|
||||
Data = datasource;
|
||||
}
|
||||
|
||||
public FPlayer SelfPlayer;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// FishingData = fishingData;
|
||||
|
||||
@@ -26,7 +26,6 @@ public partial class FPlayer : MonoBehaviour
|
||||
|
||||
public PlayerAnimator PlayerAnimatorCtrl;
|
||||
|
||||
|
||||
public FPlayerUseGear Gears;
|
||||
|
||||
public LureTrajectorySimulator LureTrajectorySimulator;
|
||||
@@ -34,6 +33,10 @@ public partial class FPlayer : MonoBehaviour
|
||||
public Transform Light;
|
||||
|
||||
public Transform BackSpine;
|
||||
|
||||
public CapsuleCollider Collider;
|
||||
|
||||
public Rigidbody Rigidbody;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -53,6 +56,7 @@ public partial class FPlayer : MonoBehaviour
|
||||
|
||||
PlayerAnimatorCtrl.Player = this;
|
||||
Arms = GetComponentsInChildren<PlayerArm>();
|
||||
Collider = GetComponent<CapsuleCollider>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -72,6 +76,7 @@ public partial class FPlayer : MonoBehaviour
|
||||
|
||||
if (data.PlayerID == GameModel.RoleID)
|
||||
{
|
||||
Fishing.Inst.Player.SelfPlayer = this;
|
||||
BaseCamera.Main.transform.SetParent(CameraRoot);
|
||||
BaseCamera.Main.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
@@ -158,6 +163,8 @@ public partial class FPlayer : MonoBehaviour
|
||||
private Tween _fovTween; // 存储当前的Tween动画,方便中断
|
||||
private float _zoomDuration = 0.2f; // 缩放动画时间
|
||||
|
||||
public Boat NowBoat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 切换望远镜效果(打开/关闭)
|
||||
/// </summary>
|
||||
@@ -183,4 +190,20 @@ public partial class FPlayer : MonoBehaviour
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void EnterBoat(Boat boat)
|
||||
{
|
||||
NowBoat = boat;
|
||||
transform.parent = boat.standPlace;
|
||||
transform.localPosition = Vector3.zero;
|
||||
Collider.enabled = false;
|
||||
Rigidbody.isKinematic = false;
|
||||
}
|
||||
|
||||
public void ExitBoat()
|
||||
{
|
||||
NowBoat = null;
|
||||
Collider.enabled = true;
|
||||
Rigidbody.isKinematic = true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerBoat.cs
Normal file
11
Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerBoat.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家船控制
|
||||
/// </summary>
|
||||
public class PlayerBoat : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2b9c0a2b0754a908bc071754c1ed74b
|
||||
timeCreated: 1748275883
|
||||
@@ -5,13 +5,11 @@ using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
|
||||
public class PlayerCharacter : Character
|
||||
{
|
||||
private float _cameraPitch;
|
||||
private FPlayer _player;
|
||||
|
||||
|
||||
[Space(10.0f)] public float maxSprintSpeed = 10.0f;
|
||||
|
||||
public GameObject cameraParent;
|
||||
@@ -25,7 +23,6 @@ namespace NBF
|
||||
[HideInInspector] public int nextShowSlotIndex = -1;
|
||||
public bool IsSelf;
|
||||
|
||||
|
||||
public LookAtIK lookAtIK; // 挂在背部上的 LookAtIK 脚本
|
||||
public float aimDistance = 1.5f; // 目标点离相机多远
|
||||
|
||||
@@ -70,7 +67,16 @@ namespace NBF
|
||||
private void Update()
|
||||
{
|
||||
InteractiveCheck();
|
||||
UpdatePlayerPositionAndRotation();
|
||||
if (_player.NowBoat)
|
||||
{
|
||||
_player.NowBoat.BoatInput(InputManager.GetMovementInput());
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePlayerPosition();
|
||||
}
|
||||
|
||||
UpdatePlayerRotation();
|
||||
UpdateGear();
|
||||
}
|
||||
|
||||
@@ -189,7 +195,7 @@ namespace NBF
|
||||
private bool _isSprinting;
|
||||
private bool _sprintInputPressed;
|
||||
|
||||
private void UpdatePlayerPositionAndRotation()
|
||||
private void UpdatePlayerPosition()
|
||||
{
|
||||
// Move
|
||||
Vector2 movementInput = InputManager.GetMovementInput();
|
||||
@@ -203,7 +209,10 @@ namespace NBF
|
||||
movementDirection.relativeTo(cameraTransform, GetUpVector());
|
||||
|
||||
SetMovementDirection(movementDirection);
|
||||
}
|
||||
|
||||
private void UpdatePlayerRotation()
|
||||
{
|
||||
// Look
|
||||
Vector2 lookInput = InputManager.GetLookInput() * sensitivity;
|
||||
|
||||
|
||||
@@ -50,7 +50,19 @@ namespace NBF
|
||||
{
|
||||
if (string.IsNullOrEmpty(_interactiveData.Use1)) return;
|
||||
Debug.Log(_interactiveData.Use1);
|
||||
UI.Inst.OpenUI<FishingShopPanel>();
|
||||
|
||||
if (_interactiveObject.Type == UIDef.InteractiveType.Boat)
|
||||
{
|
||||
//上船
|
||||
Debug.Log("上船===");
|
||||
var boat = _interactiveObject.gameObject.GetComponent<Boat>();
|
||||
Fishing.Inst.Player.SelfPlayer.EnterBoat(boat);
|
||||
// Fishing.Inst.Player
|
||||
}
|
||||
else if (_interactiveObject.Type == UIDef.InteractiveType.FishingShop)
|
||||
{
|
||||
UI.Inst.OpenUI<FishingShopPanel>();
|
||||
}
|
||||
}
|
||||
|
||||
public void Use2()
|
||||
|
||||
Reference in New Issue
Block a user