修改提交
This commit is contained in:
63
Assets/Scripts/Fishing/New/Data/MapRoom.cs
Normal file
63
Assets/Scripts/Fishing/New/Data/MapRoom.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 地图房间
|
||||
/// </summary>
|
||||
public class MapRoom : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否本地房间
|
||||
/// </summary>
|
||||
public bool IsLocalRoom;
|
||||
|
||||
/// <summary>
|
||||
/// 房间序号id
|
||||
/// </summary>
|
||||
public int RoomId;
|
||||
|
||||
/// <summary>
|
||||
/// 房间代码
|
||||
/// </summary>
|
||||
public string Code = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 房间玩家
|
||||
/// </summary>
|
||||
public Dictionary<long, Player> Units = new Dictionary<long, Player>();
|
||||
|
||||
/// <summary>
|
||||
/// 房主
|
||||
/// </summary>
|
||||
public long Owner;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public long CreateTime;
|
||||
|
||||
/// <summary>
|
||||
/// 房间地图
|
||||
/// </summary>
|
||||
public int Map;
|
||||
|
||||
public void AddUnit(MapUnitInfo unit)
|
||||
{
|
||||
var player = Create<Player>(Game.Main, unit.Id, true, true);
|
||||
Units[unit.Id] = player;
|
||||
player.InitPlayer(unit);
|
||||
}
|
||||
|
||||
public void RemoveUnit(long id)
|
||||
{
|
||||
if (Units.Remove(id, out var player))
|
||||
{
|
||||
player.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/Data/MapRoom.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/Data/MapRoom.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41009853ac444d87809e98fae2d1c597
|
||||
timeCreated: 1773036879
|
||||
97
Assets/Scripts/Fishing/New/Data/Player.cs
Normal file
97
Assets/Scripts/Fishing/New/Data/Player.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class Player : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否本地玩家
|
||||
/// </summary>
|
||||
public bool IsLocalPlayer;
|
||||
|
||||
public bool IsLureRod => false;
|
||||
|
||||
public bool IsSelf => RoleModel.Instance.Id == Id;
|
||||
|
||||
// ========== 物理状态(高频同步) ==========
|
||||
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>
|
||||
/// 标志量
|
||||
/// </summary>
|
||||
public long TagValue;
|
||||
|
||||
|
||||
// ========== 状态机 ==========
|
||||
private PlayerState _previousPlayerState = PlayerState.Idle;
|
||||
private PlayerState _playerState;
|
||||
public PlayerState PreviousState => _previousPlayerState;
|
||||
|
||||
/// <summary>
|
||||
/// 当前状态的进入参数(本地和远程都适用)
|
||||
/// </summary>
|
||||
public StateEnterParams CurrentStateParams { get; private set; } = new StateEnterParams();
|
||||
|
||||
public PlayerState State
|
||||
{
|
||||
get => _playerState;
|
||||
set
|
||||
{
|
||||
if (_playerState != value)
|
||||
{
|
||||
_previousPlayerState = _playerState;
|
||||
_playerState = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 玩家的物品
|
||||
/// </summary>
|
||||
public Dictionary<long, PlayerItem> Items = new Dictionary<long, PlayerItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 当前手持物品id
|
||||
/// </summary>
|
||||
public long HandItemId;
|
||||
|
||||
/// <summary>
|
||||
/// 当前手持物品
|
||||
/// </summary>
|
||||
public PlayerItem HandItem => Items[HandItemId];
|
||||
|
||||
public void InitPlayer(MapUnitInfo unitInfo)
|
||||
{
|
||||
AddComponent<PlayerViewComponent>();
|
||||
if (unitInfo.Id == RoleModel.Instance.Id)
|
||||
{
|
||||
//自己
|
||||
AddComponent<PlayerInputComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UnUseItem()
|
||||
{
|
||||
}
|
||||
|
||||
public void UseItem(ItemInfo item)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/Data/Player.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/Data/Player.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f7d8cb1b2cd4e25913e17e2b54e7ad9
|
||||
timeCreated: 1773036936
|
||||
12
Assets/Scripts/Fishing/New/Data/PlayerItem.cs
Normal file
12
Assets/Scripts/Fishing/New/Data/PlayerItem.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerItem : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置id
|
||||
/// </summary>
|
||||
public int ConfigID;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/Data/PlayerItem.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/Data/PlayerItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6649b122db2f46aea8147228c674a38c
|
||||
timeCreated: 1773037313
|
||||
Reference in New Issue
Block a user