大修改调整
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
using UnityEngine;
|
||||
@@ -17,18 +18,13 @@ namespace NBF
|
||||
public bool IsSelf => RoleModel.Instance.Id == Id;
|
||||
|
||||
// ========== 物理状态(高频同步) ==========
|
||||
public Vector3 position;
|
||||
public Quaternion rotation;
|
||||
public Vector3 Position;
|
||||
public Quaternion Rotation;
|
||||
public Vector2 MoveInput;
|
||||
public float Speed;
|
||||
public float RotationSpeed;
|
||||
public bool IsGrounded;
|
||||
public bool Run;
|
||||
|
||||
// ========== 钓鱼相关状态(中频同步) ==========
|
||||
public float currentReelingSpeed;
|
||||
public float lineLength;
|
||||
public float reelSpeed;
|
||||
public float EyeAngle;
|
||||
|
||||
/// <summary>
|
||||
@@ -36,29 +32,21 @@ namespace NBF
|
||||
/// </summary>
|
||||
public long TagValue;
|
||||
|
||||
|
||||
// ========== 状态机 ==========
|
||||
private PlayerState _previousPlayerState = PlayerState.Idle;
|
||||
private PlayerState _playerState;
|
||||
public PlayerState PreviousState => _previousPlayerState;
|
||||
/// <summary>
|
||||
/// 上一个状态
|
||||
/// </summary>
|
||||
public PlayerState PreviousState;
|
||||
|
||||
/// <summary>
|
||||
/// 当前状态的进入参数(本地和远程都适用)
|
||||
/// 当前状态
|
||||
/// </summary>
|
||||
public StateEnterParams CurrentStateParams { get; private set; } = new StateEnterParams();
|
||||
public PlayerState State;
|
||||
|
||||
/// <summary>
|
||||
/// 状态参数
|
||||
/// </summary>
|
||||
public StateEnterParams StateParams;
|
||||
|
||||
public PlayerState State
|
||||
{
|
||||
get => _playerState;
|
||||
set
|
||||
{
|
||||
if (_playerState != value)
|
||||
{
|
||||
_previousPlayerState = _playerState;
|
||||
_playerState = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 玩家的物品
|
||||
@@ -75,9 +63,12 @@ namespace NBF
|
||||
/// </summary>
|
||||
public PlayerItem HandItem => Items[HandItemId];
|
||||
|
||||
#region 初始化
|
||||
|
||||
public void InitPlayer(MapUnitInfo unitInfo)
|
||||
{
|
||||
AddComponent<PlayerViewComponent>();
|
||||
AddComponent<PlayerStateViewComponent>();
|
||||
if (unitInfo.Id == RoleModel.Instance.Id)
|
||||
{
|
||||
//自己
|
||||
@@ -85,13 +76,61 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 物品
|
||||
|
||||
public void UnUseItem()
|
||||
{
|
||||
if (Items.TryGetValue(HandItemId, out var item))
|
||||
{
|
||||
item.Dispose();
|
||||
}
|
||||
|
||||
HandItemId = 0;
|
||||
ItemChangeEvent();
|
||||
}
|
||||
|
||||
public void UseItem(ItemInfo item)
|
||||
public void UseItem(ItemBindInfo item)
|
||||
{
|
||||
var playerItem = Create<PlayerItem>(Scene);
|
||||
playerItem.Init(item);
|
||||
ItemChangeEvent();
|
||||
}
|
||||
|
||||
private void ItemChangeEvent()
|
||||
{
|
||||
Scene.EventComponent.Publish(new PlayerStateChangeEvent
|
||||
{
|
||||
Player = this
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 状态切换
|
||||
|
||||
/// <summary>
|
||||
/// 切换状态
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="stateParams"></param>
|
||||
public void ChangeState(PlayerState state, StateEnterParams stateParams = null)
|
||||
{
|
||||
if (state == State)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PreviousState = State;
|
||||
State = state;
|
||||
StateParams = stateParams;
|
||||
Scene.EventComponent.Publish(new PlayerStateChangeEvent
|
||||
{
|
||||
Player = this
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
12
Assets/Scripts/Fishing/New/Data/PlayerEvent.cs
Normal file
12
Assets/Scripts/Fishing/New/Data/PlayerEvent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace NBF
|
||||
{
|
||||
public struct PlayerStateChangeEvent
|
||||
{
|
||||
public Player Player;
|
||||
}
|
||||
|
||||
public struct PlayerItemChangeEvent
|
||||
{
|
||||
public Player Player;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/Data/PlayerEvent.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/Data/PlayerEvent.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c10a4d3f5e354dc9a046ddf7219354b2
|
||||
timeCreated: 1773060354
|
||||
@@ -1,4 +1,6 @@
|
||||
using Fantasy.Entitas;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
@@ -8,5 +10,16 @@ namespace NBF
|
||||
/// 配置id
|
||||
/// </summary>
|
||||
public int ConfigID;
|
||||
|
||||
/// <summary>
|
||||
/// 绑定的子物体
|
||||
/// </summary>
|
||||
public List<int> BindItems = new List<int>();
|
||||
|
||||
public void Init(ItemBindInfo bindInfo)
|
||||
{
|
||||
ConfigID = bindInfo.Item;
|
||||
BindItems.AddRange(bindInfo.BindItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user