角色预制体创建

This commit is contained in:
2025-09-03 00:15:43 +08:00
parent 48f608e534
commit 186fec4472
100 changed files with 1025 additions and 349 deletions

View File

@@ -7,13 +7,22 @@ namespace NBF
public int Error { get; set; }
}
/// <summary>
/// 相机模式切换
/// </summary>
public struct CameraChangeMode
{
public CameraShowMode Mode;
public MapUnit Unit;
}
/// <summary>
/// 开始切换场景
/// </summary>
public struct SceneChangeStart
{
}
/// <summary>
/// Loading进度变化
/// </summary>

View File

@@ -0,0 +1,68 @@
using System;
using UnityEngine;
namespace NBF
{
public enum CameraUpdateMode
{
Smooth,
Immediate,
}
public enum CameraMode
{
Third,
Free,
}
[Serializable]
public class CameraCfg
{
public CameraMode Mode;
public CameraUpdateMode UpdateMode;
public float SmoothTime;
public float NearClipPlane = 1;
public float FarClipPlane = 500;
public Vector3 Near;
public Vector3 Far;
public float BestRatio = 0.5f;
public Vector3 Distance
{
get { return this.Far - this.Near; }
}
public Vector3 Best
{
get
{
switch (Mode)
{
case CameraMode.Third:
return this.Near + (this.Far - this.Near) * this.BestRatio;
default:
return Quaternion.Euler(this.PitchBest, 0, 0) *
(Vector3.back * (this.Near + (this.Far - this.Near) * this.BestRatio).magnitude);
}
}
}
public float Yaw;
public bool YawAtThird;
public float PitchBest;
public float PitchMin;
public float PitchMax;
}
[CreateAssetMenu(menuName = "ET/CreateCameraConfig", fileName = "CameraCfg", order = 1)]
public class CameraScriptObject : ScriptableObject
{
public float ScaleTime = 6;
public CameraCfg ThirdCfg;
public CameraCfg FreeCfg;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5f43c20e40ae42239e4381c12ad7cc00
timeCreated: 1756823027

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0eb35ab0b70344b4a2b6054f7a7ecd1b
timeCreated: 1756822717

View File

@@ -0,0 +1,67 @@
using NBC;
using NBC.Entitas;
using NBC.Entitas.Interface;
using NBC.Event;
using UnityEditor;
using UnityEngine;
namespace NBF.Fishing2
{
public enum CameraShowMode
{
Player,
Free,
}
public class CameraComponent : Entity
{
public CameraShowMode Mode;
public Camera Camera;
public MapUnit MapUnit;
}
public static class CameraComponentSystem
{
public class CameraComponentAwakeSystem : AwakeSystem<CameraComponent>
{
protected override void Awake(CameraComponent self)
{
self.Camera = BaseCamera.Main;
}
}
public class CameraChangeModeEvent : EventSystem<CameraChangeMode>
{
protected override void Handler(CameraChangeMode self)
{
var cameraComponent = App.Main.GetComponent<CameraComponent>();
cameraComponent.Mode = self.Mode;
cameraComponent.MapUnit = self.Unit;
cameraComponent.ChangeCameraMode();
}
}
public static void ChangeCameraMode(this CameraComponent self)
{
if (self.Mode == CameraShowMode.Player)
{
if (self.MapUnit != null)
{
var unityComponent = self.MapUnit.GetComponent<UnitUnityComponent>();
if (unityComponent != null)
{
var root = unityComponent.Transform.Find("FPSCamera");
self.Camera.transform.SetParent(root);
self.Camera.transform.localPosition = Vector3.zero;
self.Camera.transform.localRotation = Quaternion.identity;
self.Camera.transform.localScale = Vector3.one;
}
}
}
else if (self.Mode == CameraShowMode.Free)
{
self.Camera.transform.SetParent(null);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aee3947bbf944ecb9e955d2ac1d9e3a5
timeCreated: 1756822741

View File

@@ -2,7 +2,7 @@
namespace NBF.Fishing2
{
public class MoveComponent : Entity
public class InputComponent : Entity
{
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 09132878c89a444a88421b7434394235
timeCreated: 1756826439

View File

@@ -0,0 +1,9 @@
using NBC.Entitas;
namespace NBF.Fishing2
{
public class SettingComponent : Entity
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7c6adcf67ef545f99c590d1078a76eea
timeCreated: 1756826460

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 67d5b3b1b06a4f60875ee66ec05d6205
timeCreated: 1756364079

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 7924ca863f4b4ce8a7018a42852431a6
timeCreated: 1756564816

View File

@@ -1,12 +0,0 @@
using NBC.Entitas;
namespace NBF.Fishing2
{
/// <summary>
/// 背包
/// </summary>
public class Bag : Entity
{
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 2176086bd28445acb23a458c20d016ab
timeCreated: 1756564836

View File

@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using NBC.Entitas;
namespace NBF.Fishing2
{
public class Map : Entity
{
public int MapId;
/// <summary>
/// 好友房地图
/// </summary>
public bool IsRoomMap;
/// <summary>
/// 地图中的单位
/// </summary>
public Dictionary<long, MapUnit> Units = new Dictionary<long, MapUnit>();
}
}

View File

@@ -1,12 +0,0 @@
using NBC;
using NBC.Entitas;
using NBC.Entitas.Interface;
namespace NBF.Fishing2
{
public class Role : Entity
{
public long RoomId { get; set; }
public RoleInfo Info { get; set; }
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 8e7f0c94a8514f5fa23bcc283e7abdc4
timeCreated: 1756049392

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 6e4715bc722c4438ae8603fab6232e81
timeCreated: 1756049567

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 56a84b9175e14d59ad68a999f549a821
timeCreated: 1756738863

View File

@@ -1,28 +0,0 @@
using NBC;
namespace NBF.Fishing2
{
public static class UnitSystem
{
public static void SetUnitInfo(this MapUnit self, MapUnitInfo unitInfo)
{
NumericComponent numericComponent = self.AddComponent<NumericComponent>();
foreach (var kv in unitInfo.KV)
{
numericComponent.Set(kv.Key, kv.Value);
}
}
public static UnitConfig Config(this MapUnit self)
{
return UnitConfig.Get(self.ConfigId);
}
public static UnitType Type(this MapUnit self)
{
return self.Config().Type;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 1e34ab621bcb45b1af37fca0b06878bb
timeCreated: 1756049584

View File

@@ -1,6 +1,8 @@
using System;
using NBC;
using NBC.Entitas;
using UnityEngine;
using Object = System.Object;
namespace NBF.Fishing2
{
@@ -83,9 +85,9 @@ namespace NBF.Fishing2
public static async FTask LoadMap(this Map self)
{
var sceneName = "Map99";
self.CreteSelfMapUnit();
//加载场景==
await SceneHelper.LoadScene(sceneName);
self.CreteSelfMapUnit();
await self.LoadAllUnit();
FishingPanel.Show();
@@ -96,12 +98,22 @@ namespace NBF.Fishing2
#endregion
#region Unit
/// <summary>
/// 加载所有unit单位
/// </summary>
/// <param name="self"></param>
public static async FTask LoadAllUnit(this Map self)
{
MapUnit mapUnit = null;
foreach (var (_, unit) in self.Units)
{
var unitUnity = unit.AddComponent<UnitUnityComponent>();
await unitUnity.InitUnityObject();
mapUnit = unit;
}
self.Scene.EventComponent.Publish(new CameraChangeMode() { Mode = CameraShowMode.Player, Unit = mapUnit });
}
#endregion

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using NBC;
using Unity.Mathematics;
namespace NBF.Fishing2
{
public static class MoveHelper
{
/// <summary>
/// 可以多次调用,多次调用的话会取消上一次的协程
/// </summary>
/// <param name="unit"></param>
/// <param name="targetPos"></param>
/// <returns></returns>
public static async FTask<int> MoveToAsync(this MapUnit unit, float3 targetPos)
{
return 0;
}
public static async FTask MoveToAsync(this MapUnit unit, List<float3> path)
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2ce11e50e0d749bfa5915208b1ce1a44
timeCreated: 1756822516

View File

@@ -1,27 +1,43 @@
using System;
using System.Collections.Generic;
using NBC;
using NBC.Entitas;
namespace NBF.Fishing2
{
public static class MapSystem
public class Map : Entity
{
public int MapId;
/// <summary>
/// 好友房地图
/// </summary>
public bool IsRoomMap;
/// <summary>
/// 地图中的单位
/// </summary>
public Dictionary<long, MapUnit> Units = new Dictionary<long, MapUnit>();
/// <summary>
/// 创建地图单位
/// </summary>
/// <param name="map"></param>
public static void CreteSelfMapUnit(this Map map)
public void CreteSelfMapUnit()
{
//创建自己
var role = map.Scene.GetComponent<Role>();
var role = Scene.GetComponent<Role>();
var mapUnitInfo = role.GetMapUnitInfo();
map.CreteMapUnit(mapUnitInfo);
CreteMapUnit(mapUnitInfo);
}
public static void CreteMapUnit(this Map map, MapUnitInfo unitInfo)
public void CreteMapUnit(MapUnitInfo unitInfo)
{
var mapUnit = Entity.Create<MapUnit>(map.Scene, unitInfo.RoleInfo.RoleId, true, true);
map.Add(mapUnit);
var mapUnit = Entity.Create<MapUnit>(Scene, unitInfo.RoleInfo.RoleId, true, true);
Add(mapUnit);
}
/// <summary>
@@ -30,9 +46,9 @@ namespace NBF.Fishing2
/// <param name="self"></param>
/// <param name="id"></param>
/// <returns></returns>
public static MapUnit GetUnit(this Map self, long id)
public MapUnit GetUnit(long id)
{
return self.Units.GetValueOrDefault(id);
return Units.GetValueOrDefault(id);
}
/// <summary>
@@ -41,9 +57,9 @@ namespace NBF.Fishing2
/// <param name="map"></param>
/// <param name="unit"></param>
/// <returns></returns>
public static bool Add(this Map map, MapUnit unit)
public bool Add(MapUnit unit)
{
map.Units.Add(unit.Id, unit);
Units.Add(unit.Id, unit);
return true;
}
@@ -53,9 +69,9 @@ namespace NBF.Fishing2
/// <param name="self"></param>
/// <param name="id"></param>
/// <returns></returns>
public static bool Remove(this Map self, long id)
public bool Remove(long id)
{
return self.Units.Remove(id);
return Units.Remove(id);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 53262d3faa5141deb0c8809a4354daa0
timeCreated: 1756820602

View File

@@ -0,0 +1,353 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace NBF
{
public enum ThrowModeEnum : int
{
Spin = 0,
Float = 1,
}
public enum HandItemType
{
Default = 0,
HandRod = 1,
SpinRod = 2,
}
public class PlayerAnimator : MonoBehaviour
{
#region
private static readonly int StartThrowHash = Animator.StringToHash("startThrow");
private static readonly int LureThrownHash = Animator.StringToHash("lureThrown");
private static readonly int PrepareThrowHash = Animator.StringToHash("prepareThrow");
private static readonly int LeftHandHash = Animator.StringToHash("leftHand");
private static readonly int MoveSpeedHash = Animator.StringToHash("moveSpeed");
private static readonly int BoatVelocityHash = Animator.StringToHash("boatVelocity");
private static readonly int BoatDirHash = Animator.StringToHash("boatDir");
private static readonly int BoatHash = Animator.StringToHash("boat");
private static readonly int CastingHash = Animator.StringToHash("casting");
private static readonly int TelestickHash = Animator.StringToHash("telestick");
private static readonly int TelestickPullHash = Animator.StringToHash("telestick_pull");
private static readonly int UseRodPodHash = Animator.StringToHash("use_rod_pod");
private static readonly int ItemSourceHash = Animator.StringToHash("item_source");
private static readonly int ItemDestHash = Animator.StringToHash("item_dest");
private static readonly int RodReadyHash = Animator.StringToHash("rod_ready");
private static readonly int HitchRecoverDirHash = Animator.StringToHash("hitchRecoverDir");
private static readonly int HitchRecoverHash = Animator.StringToHash("hitchRecover");
private static readonly int SitOrStandHash = Animator.StringToHash("sitOrStand");
private static readonly int ShtekerHash = Animator.StringToHash("shteker");
private static readonly int ItemInHandsHash = Animator.StringToHash("item_in_hands");
private static readonly int ChangeItemHash = Animator.StringToHash("change_item");
private static readonly int ItemTypeHash = Animator.StringToHash("item_type");
private static readonly int ItemActionHash = Animator.StringToHash("item_action");
private static readonly int ItemActionPowerHash = Animator.StringToHash("item_action_power");
private static readonly int PodsakActionHash = Animator.StringToHash("podsak_action");
private static readonly int FishingFinalHash = Animator.StringToHash("fishing_final");
private static readonly int SpinOrTeleHash = Animator.StringToHash("spin_or_tele");
private static readonly int TwitchHash = Animator.StringToHash("twitch");
private static readonly int TwitchDirHash = Animator.StringToHash("twitch_dir");
private static readonly int ThrowSpeedMultHash = Animator.StringToHash("throw_speed_mult");
private static readonly int ConvTestHash = Animator.StringToHash("conv_test");
private static readonly int BoatPoseHash = Animator.StringToHash("boat_pose");
private static readonly int QuadDirectionHash = Animator.StringToHash("quad_direction");
private static readonly int StretchMaxHash = Animator.StringToHash("stretch_max");
private static readonly int ExamineItemHash = Animator.StringToHash("examine_item");
private static readonly int TillerDirectionHash = Animator.StringToHash("tiller_direction");
private static readonly int TestTriggerHash = Animator.StringToHash("test_trigger");
private static readonly int ThrowModeHash = Animator.StringToHash("throw_mode");
private static readonly int PullUpRodHash = Animator.StringToHash("pull_up_rod");
public bool StartThrow
{
get => animator.GetBool(StartThrowHash);
set => animator.SetBool(StartThrowHash, value);
}
public bool LureThrown
{
get => animator.GetBool(LureThrownHash);
set => animator.SetBool(LureThrownHash, value);
}
public bool PrepareThrow
{
get => animator.GetBool(PrepareThrowHash);
set => animator.SetBool(PrepareThrowHash, value);
}
public bool LeftHand
{
get => animator.GetBool(LeftHandHash);
set => animator.SetBool(LeftHandHash, value);
}
public float MoveSpeed
{
get => animator.GetFloat(MoveSpeedHash);
set => animator.SetFloat(MoveSpeedHash, value);
}
public float BoatVelocity
{
get => animator.GetFloat(BoatVelocityHash);
set => animator.SetFloat(BoatVelocityHash, value);
}
public float BoatDir
{
get => animator.GetFloat(BoatDirHash);
set => animator.SetFloat(BoatDirHash, value);
}
public bool Boat
{
get => animator.GetBool(BoatHash);
set => animator.SetBool(BoatHash, value);
}
public bool Casting
{
get => animator.GetBool(CastingHash);
set => animator.SetBool(CastingHash, value);
}
public bool Telestick
{
get => animator.GetBool(TelestickHash);
set => animator.SetBool(TelestickHash, value);
}
public bool TelestickPull
{
get => animator.GetBool(TelestickPullHash);
set => animator.SetBool(TelestickPullHash, value);
}
public bool UseRodPod
{
get => animator.GetBool(UseRodPodHash);
set => animator.SetBool(UseRodPodHash, value);
}
public int ItemSource
{
get => animator.GetInteger(ItemSourceHash);
set => animator.SetInteger(ItemSourceHash, value);
}
public int ItemDest
{
get => animator.GetInteger(ItemDestHash);
set => animator.SetInteger(ItemDestHash, value);
}
public bool RodReady
{
get => animator.GetBool(RodReadyHash);
set => animator.SetBool(RodReadyHash, value);
}
public float HitchRecoverDir
{
get => animator.GetFloat(HitchRecoverDirHash);
set => animator.SetFloat(HitchRecoverDirHash, value);
}
public void SetHitchRecoverTrigger()
{
animator.SetTrigger(HitchRecoverHash);
}
public void ResetHitchRecoverTrigger()
{
animator.ResetTrigger(HitchRecoverHash);
}
public float SitOrStand
{
get => animator.GetFloat(SitOrStandHash);
set => animator.SetFloat(SitOrStandHash, value);
}
public bool Shteker
{
get => animator.GetBool(ShtekerHash);
set => animator.SetBool(ShtekerHash, value);
}
public bool ItemInHands
{
get => animator.GetBool(ItemInHandsHash);
set => animator.SetBool(ItemInHandsHash, value);
}
public bool ChangeItem
{
get => animator.GetBool(ChangeItemHash);
set => animator.SetBool(ChangeItemHash, value);
}
public HandItemType ItemType
{
get => (HandItemType)animator.GetInteger(ItemTypeHash);
set => animator.SetInteger(ItemTypeHash, (int)value);
}
public void SetItemActionTrigger()
{
animator.SetTrigger(ItemActionHash);
}
public void ResetItemActionTrigger()
{
animator.ResetTrigger(ItemActionHash);
}
public float ItemActionPower
{
get => animator.GetFloat(ItemActionPowerHash);
set => animator.SetFloat(ItemActionPowerHash, value);
}
public bool PodsakAction
{
get => animator.GetBool(PodsakActionHash);
set => animator.SetBool(PodsakActionHash, value);
}
public bool PullUpRod
{
get => animator.GetBool(PullUpRodHash);
set => animator.SetBool(PullUpRodHash, value);
}
public float FishingFinal
{
get => animator.GetFloat(FishingFinalHash);
set => animator.SetFloat(FishingFinalHash, value);
}
public float SpinOrTele
{
get => animator.GetFloat(SpinOrTeleHash);
set => animator.SetFloat(SpinOrTeleHash, value);
}
public void SetTwitchTrigger()
{
animator.SetTrigger(TwitchHash);
}
public void ResetTwitchTrigger()
{
animator.ResetTrigger(TwitchHash);
}
public float TwitchDir
{
get => animator.GetFloat(TwitchDirHash);
set => animator.SetFloat(TwitchDirHash, value);
}
public float ThrowSpeedMult
{
get => animator.GetFloat(ThrowSpeedMultHash);
set => animator.SetFloat(ThrowSpeedMultHash, value);
}
public void SetConvTestTrigger()
{
animator.SetTrigger(ConvTestHash);
}
public void ResetConvTestTrigger()
{
animator.ResetTrigger(ConvTestHash);
}
public int BoatPose
{
get => animator.GetInteger(BoatPoseHash);
set => animator.SetInteger(BoatPoseHash, value);
}
public float QuadDirection
{
get => animator.GetFloat(QuadDirectionHash);
set => animator.SetFloat(QuadDirectionHash, value);
}
public bool StretchMax
{
get => animator.GetBool(StretchMaxHash);
set => animator.SetBool(StretchMaxHash, value);
}
public void SetExamineItemTrigger()
{
animator.SetTrigger(ExamineItemHash);
}
public void ResetExamineItemTrigger()
{
animator.ResetTrigger(ExamineItemHash);
}
public float TillerDirection
{
get => animator.GetFloat(TillerDirectionHash);
set => animator.SetFloat(TillerDirectionHash, value);
}
public void SetTestTrigger()
{
animator.SetTrigger(TestTriggerHash);
}
public void ResetTestTrigger()
{
animator.ResetTrigger(TestTriggerHash);
}
public ThrowModeEnum ThrowMode
{
get
{
var val = animator.GetInteger(ThrowModeHash);
return (ThrowModeEnum)val;
}
set => animator.SetInteger(ThrowModeHash, (int)value);
}
#endregion
// public FPlayer Player;
public Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
#region
/// <summary>
/// 抛竿开始
/// </summary>
public void RodForceThrowStart()
{
// if (Player.Fsm.CurrentState is PlayerThrow playerThrow)
// {
// playerThrow.RodForceThrowStart();
// }
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cddbe2f2da274f6196485f744b618c86
timeCreated: 1756820608

View File

@@ -0,0 +1,58 @@
using RootMotion.FinalIK;
using UnityEngine;
namespace NBF
{
public class PlayerArm : MonoBehaviour
{
public bool IsLeft;
public LimbIK IK;
public Transform RodContainer;
public Transform LeftRigMagnet;
public FingerRig FingerRig;
public PlayerShoulder Shoulder;//PlayerShoulder
[HideInInspector] public float interactionTargetWeight;
public void SetReelHandle(ReelAsset asset)
{
IK.solver.target = asset.handle;
IK.enabled = true;
// var fingers = FingerRig.fingers;
// foreach (var finger in fingers)
// {
// finger.target = asset.handleEnd;
// }
// // 启用整体控制
// FingerRig.weight = 1f;
//
// // 绑定大拇指和食指的目标
// FingerRig.fingers[0].target = asset.handleEnd; // Thumb
// FingerRig.fingers[1].target = asset.handleEnd; // Index
//
// FingerRig.fingers[0].weight = 1f;
// FingerRig.fingers[1].weight = 1f;
// 其余手指握拳(不绑定 target
for (int i = 2; i < 5; i++)
{
FingerRig.fingers[i].target = null;
FingerRig.fingers[i].weight = 1f;
}
}
public void MoveTowardsInteraction()
{
if (!IK)
{
return;
}
IK.solver.SetIKPositionWeight(Mathf.MoveTowards(IK.solver.IKPositionWeight,
interactionTargetWeight, Time.deltaTime * 2f));
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed33e261a2784ee0814ceaa6c88aefdf
timeCreated: 1756821001

View File

@@ -0,0 +1,37 @@
using System;
using UnityEngine;
namespace NBF
{
public class PlayerShoulder : MonoBehaviour
{
private Vector3 startEulerAngles;
private const int MaxAngle = 30;
private const int MinAngle = -30;
public float TestZ;
private void Awake()
{
startEulerAngles = transform.localEulerAngles;
}
public void SetCameraEulerAngleX(float value)
{
value = (value > 180f) ? value - 360f : value;
Debug.Log($"value={value}");
var addValue = value * -1;
if (addValue > MaxAngle)
{
addValue = MaxAngle;
}
else if (addValue < MinAngle)
{
addValue = MinAngle;
}
transform.localEulerAngles =
new Vector3(addValue + startEulerAngles.x, startEulerAngles.y, TestZ);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f85286904d2d45738c4b415f3503d4ab
timeCreated: 1756820965

View File

@@ -0,0 +1,62 @@
using System.Collections.Generic;
using NBC;
using NBC.Entitas;
using Unity.Mathematics;
namespace NBF.Fishing2
{
public class MoveComponent : Entity
{
public float3 PreTarget
{
get { return this.Targets[this.N - 1]; }
}
public float3 NextTarget
{
get { return this.Targets[this.N]; }
}
// 开启移动协程的时间
public long BeginTime;
// 每个点的开始时间
public long StartTime { get; set; }
// 开启移动协程的Unit的位置
public float3 StartPos;
public float3 RealPos
{
get { return this.Targets[0]; }
}
private long needTime;
public long NeedTime
{
get { return this.needTime; }
set { this.needTime = value; }
}
public long MoveTimer;
public float Speed; // m/s
public FTask<bool> tcs;
public List<float3> Targets = new List<float3>();
public float3 FinalTarget
{
get { return this.Targets[^1]; }
}
public int N;
public int TurnTime;
public bool IsTurnHorizontal;
public quaternion From;
public quaternion To;
}
}

View File

@@ -1,10 +1,15 @@
using NBC;
using NBC.Entitas;
using NBC.Entitas.Interface;
namespace NBF.Fishing2
{
public static class RoleSystem
public class Role : Entity
{
public long RoomId { get; set; }
public RoleInfo Info { get; set; }
public class RoleDestroySystem : DestroySystem<Role>
{
protected override void Destroy(Role self)
@@ -14,22 +19,21 @@ namespace NBF.Fishing2
}
}
public static async FTask GetRoleInfo(this Role self)
public async FTask GetRoleInfo()
{
var response = (Game2C_GetRoleInfoResponse)await Net.Call(new C2Game_GetRoleInfoRequest());
self.RoomId = response.RoomId;
self.Info = response.RoleInfo;
RoomId = response.RoomId;
Info = response.RoleInfo;
}
public static MapUnitInfo GetMapUnitInfo(this Role self)
public MapUnitInfo GetMapUnitInfo()
{
MapUnitInfo mapUnit = new MapUnitInfo();
mapUnit.Id = self.Id;
mapUnit.Id = Id;
mapUnit.RoleInfo = new RoleSimpleInfo()
{
};
return mapUnit;
}
}

View File

@@ -61,5 +61,25 @@ namespace NBF.Fishing2
}
#endregion
public void SetUnitInfo(MapUnitInfo unitInfo)
{
NumericComponent numericComponent = AddComponent<NumericComponent>();
foreach (var kv in unitInfo.KV)
{
numericComponent.Set(kv.Key, kv.Value);
}
}
public UnitConfig Config()
{
return UnitConfig.Get(ConfigId);
}
public UnitType UnitType()
{
return Config().Type;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b2120457449841468649709d6b193c35
timeCreated: 1756821388

View File

@@ -0,0 +1,49 @@
using NBC;
using NBC.Entitas;
using NBC.Entitas.Interface;
using UnityEngine;
namespace NBF.Fishing2
{
/// <summary>
/// Unit 对应的unity对象组件
/// </summary>
public class UnitUnityComponent : Entity
{
public GameObject GameObject { get; set; }
public Transform Transform { get; set; }
public Animator Animator { get; set; }
public async FTask InitUnityObject()
{
var gameObject = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
GameObject = gameObject;
Transform = gameObject.transform;
Animator = gameObject.GetComponent<Animator>();
}
public class UnitUnityComponentDestroySystem : DestroySystem<UnitUnityComponent>
{
protected override void Destroy(UnitUnityComponent self)
{
self.Animator = null;
self.GameObject = null;
self.Transform = null;
}
}
// public static void InitGameObject(this UnitUnityComponent self)
// {
// var unit = self.Parent as MapUnit;
// var prefab = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
//
// self.GameObject = prefab;
// self.Transform = prefab.transform;
// self.Animator = prefab.GetComponent<Animator>();
// }
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 944bb9e5d3fe4517bc6d12f723f98f87
timeCreated: 1756305300

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 3148c2caaafd4a099b9bc156fce7a3f7
timeCreated: 1756450740

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: ce6182010e784256ba7127a8ffa8d056
timeCreated: 1756364880

View File

@@ -1,39 +0,0 @@
using NBC;
using NBC.Entitas.Interface;
using UnityEngine;
namespace NBF.Fishing2
{
public static partial class UnitUnityComponentSystem
{
public class UnitUnityComponentAwakeSystem : AwakeSystem<UnitUnityComponent>
{
protected override void Awake(UnitUnityComponent self)
{
Log.Info("UnitUnityComponentAwakeSystem");
self.InitGameObject();
}
}
public class UnitUnityComponentDestroySystem : DestroySystem<UnitUnityComponent>
{
protected override void Destroy(UnitUnityComponent self)
{
self.Animator = null;
self.GameObject = null;
self.Transform = null;
}
}
public static void InitGameObject(this UnitUnityComponent self)
{
var unit = self.Parent as MapUnit;
var prefab = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
self.GameObject = prefab;
self.Transform = prefab.transform;
self.Animator = prefab.GetComponent<Animator>();
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: f218930cc1994aaf88752a49dc9aa4b1
timeCreated: 1756049422

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: a0e14a90077c49ed84df06845dc694f0
timeCreated: 1755919232

View File

@@ -1,17 +0,0 @@
using NBC.Entitas;
using UnityEngine;
namespace NBF.Fishing2
{
/// <summary>
/// Unit 对应的unity对象组件
/// </summary>
public class UnitUnityComponent : Entity
{
public GameObject GameObject { get; set; }
public Transform Transform { get; set; }
public Animator Animator { get; set; }
}
}

26
Assets/Scripts/Global.cs Normal file
View File

@@ -0,0 +1,26 @@
using System;
using UnityEngine;
namespace NBF
{
public class Global : MonoBehaviour
{
public static Global Instance { get; private set; }
/// <summary>
/// 主摄像机
/// </summary>
public Camera MainCamera { get; private set; }
/// <summary>
/// 摄像机配置
/// </summary>
public CameraScriptObject CameraConfig { get; private set; }
private void Awake()
{
Instance = this;
CameraConfig = Resources.Load<CameraScriptObject>(nameof(CameraConfig));
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 55a2b6b470ce459c8ca8cda7eadb8934
timeCreated: 1756823233

View File

@@ -45,7 +45,6 @@ namespace NBF
QualitySettings.vSyncCount = 0;
InitLanguage();
InitService();
InitUI();
if (!playVideo)
{
@@ -98,30 +97,6 @@ namespace NBF
#endregion
#region Service
// private static readonly List<MonoService> Services = new List<MonoService>();
private static readonly Dictionary<Type, MonoService> Services = new Dictionary<Type, MonoService>();
private void AddService<T>() where T : MonoService, new()
{
var service = this.GetComponent<T>();
if (!service)
{
service = gameObject.AddComponent<T>();
}
Services[typeof(T)] = service;
}
private void InitService()
{
AddService<InputManager>();
AddService<Settings>();
}
#endregion
public void StartGame()
{
PermanentCommon.Init();
@@ -135,13 +110,6 @@ namespace NBF
private void LoadData()
{
ConfigAssets.Init();
// var inventoryManager = GetComponent<InventoryManager>();
// if (inventoryManager == null)
// {
// inventoryManager = gameObject.AddComponent<InventoryManager>();
// }
//InventoryManager
}
#region New

View File

@@ -4,7 +4,7 @@ using UnityEngine;
namespace NBC
{
public class App : MonoBehaviour
public partial class App : MonoBehaviour
{
public static App Inst { get; private set; }

View File

@@ -13,6 +13,9 @@ namespace NBF.Fishing2
Log.Info("OnSceneCreate_Init=== root");
scene.AddComponent<ObjectWait>();
scene.AddComponent<MapManageComponent>();
scene.AddComponent<CameraComponent>();
scene.AddComponent<InputComponent>();
scene.AddComponent<SettingComponent>();
}
await FTask.CompletedTask;