提交修改
This commit is contained in:
@@ -90,6 +90,8 @@ namespace NBF
|
||||
{
|
||||
}
|
||||
|
||||
#region 鱼线操作
|
||||
|
||||
public void TakeLine()
|
||||
{
|
||||
if (Player == null) return;
|
||||
@@ -124,6 +126,71 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 鱼竿操作
|
||||
|
||||
protected void RodUpDown()
|
||||
{
|
||||
PlayerState ret = PlayerState.None;
|
||||
var isUpRod = false;
|
||||
var isSubLine = false;
|
||||
|
||||
if (InputManager.IsOp1)
|
||||
{
|
||||
if (!Player.IsLureRod)
|
||||
{
|
||||
//抬杆
|
||||
isUpRod = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//收线
|
||||
isSubLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (InputManager.IsOp2)
|
||||
{
|
||||
if (Player.IsLureRod)
|
||||
{
|
||||
//抬杆
|
||||
isUpRod = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isUpRod || PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp > 0)
|
||||
{
|
||||
var upForce = 1;
|
||||
var addNum = upForce * Time.deltaTime;
|
||||
if (!isUpRod)
|
||||
{
|
||||
addNum *= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
addNum *= 0.5f;
|
||||
}
|
||||
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp += addNum;
|
||||
Debug.Log($"addNum={addNum} ishingFinal={PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp}");
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 1)
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 1;
|
||||
}
|
||||
else if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp < 0)
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public FRod GetRod()
|
||||
{
|
||||
var view = Player.GetComponent<PlayerView>();
|
||||
|
||||
@@ -2,5 +2,28 @@
|
||||
{
|
||||
public class PlayerStageViewFight : PlayerStageViewBase
|
||||
{
|
||||
protected override void OnEnter()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnExit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
PlayerState ret = PlayerState.None;
|
||||
RodUpDown();
|
||||
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 0.8f)
|
||||
{
|
||||
// ret = CheckTackFish();
|
||||
}
|
||||
|
||||
if (ret != PlayerState.None)
|
||||
{
|
||||
Player.ChangeState(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,86 +12,96 @@ namespace NBF
|
||||
|
||||
protected override void OnExit()
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.BaitThrown = false;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
PlayerState ret = PlayerState.None;
|
||||
var isUpRod = false;
|
||||
var isSubLine = false;
|
||||
RodUpDown();
|
||||
|
||||
if (InputManager.IsOp1)
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 0.8f)
|
||||
{
|
||||
if (!Player.IsLureRod)
|
||||
{
|
||||
//抬杆
|
||||
isUpRod = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//收线
|
||||
isSubLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (InputManager.IsOp2)
|
||||
{
|
||||
if (Player.IsLureRod)
|
||||
{
|
||||
//抬杆
|
||||
isUpRod = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Player.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
|
||||
if (isUpRod || PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp > 0)
|
||||
{
|
||||
var upForce = 1;
|
||||
var addNum = upForce * Time.deltaTime;
|
||||
if (!isUpRod)
|
||||
{
|
||||
addNum *= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
addNum *= 0.5f;
|
||||
}
|
||||
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp += addNum;
|
||||
Debug.Log($"addNum={addNum} ishingFinal={PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp}");
|
||||
// Debug.LogError($"ishingFinal={PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp}");
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 1)
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 1;
|
||||
}
|
||||
else if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp < 0)
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
}
|
||||
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 0.8f)
|
||||
{
|
||||
ret = CheckTackFish();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
ret = CheckTackFish();
|
||||
}
|
||||
|
||||
if (ret != PlayerState.None)
|
||||
{
|
||||
Player.ChangeState(ret);
|
||||
}
|
||||
|
||||
// var isUpRod = false;
|
||||
// var isSubLine = false;
|
||||
//
|
||||
// if (InputManager.IsOp1)
|
||||
// {
|
||||
// if (!Player.IsLureRod)
|
||||
// {
|
||||
// //抬杆
|
||||
// isUpRod = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //收线
|
||||
// isSubLine = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (InputManager.IsOp2)
|
||||
// {
|
||||
// if (Player.IsLureRod)
|
||||
// {
|
||||
// //抬杆
|
||||
// isUpRod = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (isUpRod || PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp > 0)
|
||||
// {
|
||||
// var upForce = 1;
|
||||
// var addNum = upForce * Time.deltaTime;
|
||||
// if (!isUpRod)
|
||||
// {
|
||||
// addNum *= -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// addNum *= 0.5f;
|
||||
// }
|
||||
//
|
||||
// PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp += addNum;
|
||||
// Debug.Log($"addNum={addNum} ishingFinal={PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp}");
|
||||
// if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 1)
|
||||
// {
|
||||
// PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 1;
|
||||
// }
|
||||
// else if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp < 0)
|
||||
// {
|
||||
// PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
// }
|
||||
//
|
||||
// if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 0.8f)
|
||||
// {
|
||||
// ret = CheckTackFish();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
// }
|
||||
//
|
||||
// if (ret != PlayerState.None)
|
||||
// {
|
||||
// Player.ChangeState(ret);
|
||||
// }
|
||||
}
|
||||
|
||||
#region 检查上鱼或者返回待机
|
||||
|
||||
private PlayerState CheckTackFish()
|
||||
{
|
||||
return PlayerState.Idle;
|
||||
// return PlayerState.Idle;
|
||||
return PlayerState.Fight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{
|
||||
protected override void OnEnter()
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.BaitThrown = false;
|
||||
InputManager.OnOp1Action += OnOp1Action;
|
||||
TakeLine();
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace NBF
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// return 0;
|
||||
|
||||
//第一个节点到竿稍的位置-第一段鱼线长度
|
||||
return Vector3.Distance(Bobber.transform.position, Bobber.JointRb.transform.position) -
|
||||
|
||||
@@ -311,7 +311,8 @@ namespace NBF
|
||||
|
||||
private List<float> previousWeights = Enumerable.Repeat(0f, 10).ToList();
|
||||
private float bendSmooth = 1f;
|
||||
public float maxRodStrength = 10f;
|
||||
public float maxRodStrength = 1f;
|
||||
|
||||
public float CurrentTension01
|
||||
{
|
||||
get
|
||||
@@ -330,109 +331,54 @@ namespace NBF
|
||||
return Mathf.Clamp01(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BendControl()
|
||||
{
|
||||
var _ccdik = Asset.CCDIK;
|
||||
|
||||
// Vector3 vector = (FishEntity.CurrentFishInFight
|
||||
// ? FishEntity.CurrentFishInFight.transform.position
|
||||
// : fishingLine.currentLineHandler.LineConnector_1.transform.position);
|
||||
|
||||
var isThrowing = PlayerItem.Owner.State >= PlayerState.Fishing;
|
||||
|
||||
Vector3 vector = Line.Bobber.transform.position;
|
||||
//
|
||||
// float num = Vector3.Distance(_ccdik.solver.bones.Last().transform.position, vector);
|
||||
// float num2 = 0.05f;
|
||||
// if (currentFish)
|
||||
// {
|
||||
// float num3 = Vector3.Angle(base.transform.forward,
|
||||
// (currentFish.transform.position - transform.position).normalized) / 180f;
|
||||
// num2 = Mathf.Clamp(CurrentTension01 * num3, 0.05f, 1f);
|
||||
// }
|
||||
// else if (!isThrowing)
|
||||
// {
|
||||
// float num4 = 0.3f;
|
||||
// if (Lure)
|
||||
// {
|
||||
// num4 *= 0.6f;
|
||||
// }
|
||||
//
|
||||
// if (Bobber)
|
||||
// {
|
||||
// num4 *= 0.8f;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// float num5 = 1.5f;
|
||||
// if (num < num5)
|
||||
// {
|
||||
// num2 = Mathf.Lerp(num2, num4, 1f - num / num5);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// float num6 = 0.3f;
|
||||
// if (isThrowing)
|
||||
// {
|
||||
// num6 = 0.1f;
|
||||
// }
|
||||
// else if (!currentFish)
|
||||
// {
|
||||
// num6 = 0.2f;
|
||||
// }
|
||||
var state = PlayerItem.Owner.State;
|
||||
|
||||
// float target = num2 * num6;
|
||||
|
||||
float target = 0;
|
||||
|
||||
float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, target, Time.deltaTime * bendSmooth);
|
||||
Vector3 vector = Line.Lure.transform.position;
|
||||
|
||||
// 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
||||
float headingAlignment = Vector3.Angle(base.transform.forward,
|
||||
(Line.Lure.transform.position - transform.position).normalized) / 180f;
|
||||
// 经过朝向调制后的有效张力
|
||||
var effectiveTension = Mathf.Clamp(CurrentTension01 * headingAlignment, 0f, 1f);
|
||||
|
||||
float multiple = 0;
|
||||
if (state == PlayerState.Fight)
|
||||
{
|
||||
multiple = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiple = 0.1f;
|
||||
}
|
||||
|
||||
float targetWeight = effectiveTension * multiple;
|
||||
if (targetWeight > 0)
|
||||
{
|
||||
// Debug.Log($"CurrentTension01={CurrentTension01} LinelenghtDiferent={Line.LinelenghtDiferent} Tension={PlayerItem.Tension} num2={effectiveTension} num3={headingAlignment} num6={multiple}");
|
||||
}
|
||||
|
||||
if (state == PlayerState.Prepare)
|
||||
{
|
||||
targetWeight = 0.002f;
|
||||
}
|
||||
|
||||
float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, targetWeight, Time.deltaTime * bendSmooth);
|
||||
previousWeights.RemoveAt(0);
|
||||
previousWeights.Add(item);
|
||||
float num7 = previousWeights.Average();
|
||||
// if ((bool)FishEntity.CurrentFishInFight && FishEntity.CurrentFishInFight.IsCatched)
|
||||
if(currentFish)
|
||||
float averageWeight = previousWeights.Average();
|
||||
if (currentFish)
|
||||
{
|
||||
num7 = Math.Min(num7, 0.01f);
|
||||
averageWeight = Math.Min(averageWeight, 0.01f);
|
||||
}
|
||||
|
||||
_ccdik.solver.SetIKPosition(vector);
|
||||
_ccdik.solver.SetIKPositionWeight(num7);
|
||||
|
||||
// if (!currentFish)
|
||||
// {
|
||||
// //未中鱼
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Vector3 vector = (FishEntity.CurrentFishInFight
|
||||
// // ? FishEntity.CurrentFishInFight.transform.position
|
||||
// // : fishingLine.currentLineHandler.LineConnector_1.transform.position);
|
||||
//
|
||||
// var ccdik = Asset.CCDIK;
|
||||
//
|
||||
// Vector3 vector = Line.Bobber.transform.position;
|
||||
// // float num = Vector3.Distance(ccdik.solver.bones.Last().transform.position, vector);
|
||||
// float num2 = 0.05f;
|
||||
//
|
||||
// float num6 = 0.3f;
|
||||
// // if (isThrowing)
|
||||
// // {
|
||||
// // num6 = 0.1f;
|
||||
// // }
|
||||
// // else if (!FishEntity.CurrentFishInFight)
|
||||
// // {
|
||||
// // num6 = 0.2f;
|
||||
// // }
|
||||
//
|
||||
// float target = num2 * num6;
|
||||
// float item = Mathf.MoveTowards(ccdik.solver.IKPositionWeight, target, Time.deltaTime * bendSmooth);
|
||||
// previousWeights.RemoveAt(0);
|
||||
// previousWeights.Add(item);
|
||||
// float num7 = previousWeights.Average();
|
||||
//
|
||||
// ccdik.solver.SetIKPosition(vector);
|
||||
// ccdik.solver.SetIKPositionWeight(num7);
|
||||
_ccdik.solver.SetIKPositionWeight(averageWeight);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user