首次提交
This commit is contained in:
3
Assets/Scripts/Fishing~/Data/Datasource.meta
Normal file
3
Assets/Scripts/Fishing~/Data/Datasource.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a1247222af84a66be775a4fe0af9a57
|
||||
timeCreated: 1744041263
|
||||
199
Assets/Scripts/Fishing~/Data/Datasource/FishingDatasource.cs
Normal file
199
Assets/Scripts/Fishing~/Data/Datasource/FishingDatasource.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 钓鱼数据源基类
|
||||
/// </summary>
|
||||
public class FishingDatasource
|
||||
{
|
||||
public readonly Dictionary<int, FPlayerData> Players = new Dictionary<int, FPlayerData>();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
var p = GetTestPlayer(i);
|
||||
AddPlayer(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AddPlayer(FPlayerData player)
|
||||
{
|
||||
Players[player.PlayerID] = player;
|
||||
}
|
||||
|
||||
public FPlayerData GetPlayer(int playerID)
|
||||
{
|
||||
return Players.GetValueOrDefault(playerID);
|
||||
}
|
||||
|
||||
public FPlayerData GetSelfPlayer()
|
||||
{
|
||||
return GetPlayer(GameModel.RoleID);
|
||||
}
|
||||
|
||||
|
||||
#region 测试数据
|
||||
|
||||
public void SetSelfTestGear(int slot)
|
||||
{
|
||||
var player = GetSelfPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
player.currentGear = new FPlayerGearData();
|
||||
var gear = player.currentGear;
|
||||
|
||||
if (slot == 1)
|
||||
{
|
||||
player.lineLength = 3.6f;
|
||||
gear.Type = GearType.Pole;
|
||||
gear.rod = new FRodData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 100001,
|
||||
};
|
||||
gear.line = new FLineData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 400001
|
||||
};
|
||||
gear.bobber = new FBobberData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 300001
|
||||
};
|
||||
gear.hook = new FHookData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 700001
|
||||
};
|
||||
gear.bait = new FBaitData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 500002
|
||||
};
|
||||
gear.weight = new FWeightData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 800001
|
||||
};
|
||||
gear.reel = null;
|
||||
}
|
||||
else if (slot == 2)
|
||||
{
|
||||
player.lineLength = 0.4f;
|
||||
gear.Type = GearType.SpinningFloat;
|
||||
gear.rod = new FRodData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 100002
|
||||
};
|
||||
gear.reel = new FReelData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 200001
|
||||
};
|
||||
gear.line = new FLineData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 400001
|
||||
};
|
||||
gear.bait = new FBaitData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 500002
|
||||
};
|
||||
gear.bobber = new FBobberData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 300001
|
||||
};
|
||||
gear.hook = new FHookData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 700001
|
||||
};
|
||||
gear.weight = new FWeightData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 800001
|
||||
};
|
||||
}
|
||||
else if (slot == 3)
|
||||
{
|
||||
player.lineLength = 0.4f;
|
||||
gear.Type = GearType.Spinning;
|
||||
gear.bobber = null;
|
||||
gear.rod = new FRodData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 100003,
|
||||
};
|
||||
gear.reel = new FReelData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 200001
|
||||
};
|
||||
gear.line = new FLineData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 400001
|
||||
};
|
||||
gear.leader = new FLeaderData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 0
|
||||
};
|
||||
gear.lure = new FLureData()
|
||||
{
|
||||
id = Random.Range(1, 100000),
|
||||
configId = 600001
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FPlayerData GetTestPlayer(int index)
|
||||
{
|
||||
FPlayerData player = new FPlayerData
|
||||
{
|
||||
PlayerID = 100 + index
|
||||
};
|
||||
|
||||
var add = 0;//Random.Range(0, 5f) + index * 0.5f;
|
||||
|
||||
player.position = new Vector3(325.04f + add, 11, 606.28f);
|
||||
player.rotation = quaternion.identity;
|
||||
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
player.currentGear = new FPlayerGearData();
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
player.currentGear = new FPlayerGearData();
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b5a6200eb494c0ea9cb0bbe8345046c
|
||||
timeCreated: 1744041274
|
||||
316
Assets/Scripts/Fishing~/Data/FPlayerData.cs
Normal file
316
Assets/Scripts/Fishing~/Data/FPlayerData.cs
Normal file
@@ -0,0 +1,316 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public class FPlayerData
|
||||
{
|
||||
public int PlayerID;
|
||||
|
||||
/// <summary>
|
||||
/// 玩家当前装备的钓组
|
||||
/// </summary>
|
||||
public FPlayerGearData currentGear;
|
||||
|
||||
/// <summary>
|
||||
/// 玩家位置
|
||||
/// </summary>
|
||||
public Vector3 position;
|
||||
|
||||
/// <summary>
|
||||
/// 玩家角度
|
||||
/// </summary>
|
||||
public Quaternion rotation;
|
||||
|
||||
public float currentReelingSpeed;
|
||||
public bool isHandOnHandle;
|
||||
|
||||
/// <summary>
|
||||
/// 线长度
|
||||
/// </summary>
|
||||
public float lineLength;
|
||||
|
||||
/// <summary>
|
||||
/// 收线速度
|
||||
/// </summary>
|
||||
public float reelSpeed;
|
||||
|
||||
/// <summary>
|
||||
/// 打开手电筒
|
||||
/// </summary>
|
||||
public bool openLight;
|
||||
|
||||
/// <summary>
|
||||
/// 打开望远镜
|
||||
/// </summary>
|
||||
public bool openTelescope;
|
||||
|
||||
|
||||
public SelectorRodSetting selectorRodSetting = SelectorRodSetting.Speed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 玩家钓组数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FPlayerGearData
|
||||
{
|
||||
public GearType Type = GearType.Spinning;
|
||||
|
||||
public FRodData rod;
|
||||
public FReelData reel;
|
||||
public FBobberData bobber;
|
||||
public FHookData hook;
|
||||
public FBaitData bait;
|
||||
public FLureData lure;
|
||||
public FWeightData weight;
|
||||
public FLineData line;
|
||||
public FLeaderData leader;
|
||||
public FFeederData feeder;
|
||||
|
||||
/// <summary>
|
||||
/// 获得唯一id
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetUnitId()
|
||||
{
|
||||
int result = 0;
|
||||
if (rod != null)
|
||||
{
|
||||
result += rod.configId;
|
||||
}
|
||||
|
||||
if (reel != null)
|
||||
{
|
||||
result += reel.configId;
|
||||
}
|
||||
|
||||
if (bobber != null)
|
||||
{
|
||||
result += bobber.configId;
|
||||
}
|
||||
|
||||
if (hook != null)
|
||||
{
|
||||
result += hook.configId;
|
||||
}
|
||||
|
||||
if (bait != null)
|
||||
{
|
||||
result += bait.configId;
|
||||
}
|
||||
|
||||
if (lure != null)
|
||||
{
|
||||
result += lure.configId;
|
||||
}
|
||||
|
||||
if (weight != null)
|
||||
{
|
||||
result += weight.configId;
|
||||
}
|
||||
|
||||
if (line != null)
|
||||
{
|
||||
result += line.configId;
|
||||
}
|
||||
|
||||
if (leader != null)
|
||||
{
|
||||
result += leader.configId;
|
||||
}
|
||||
|
||||
if (feeder != null)
|
||||
{
|
||||
result += feeder.configId;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetBobberLastSetGroundValue(float value)
|
||||
{
|
||||
bobber.lastSetGroundValue = value;
|
||||
}
|
||||
|
||||
public void SetReelSettings(int setType, float val, bool saveToPrefs = false)
|
||||
{
|
||||
if (setType == 0)
|
||||
{
|
||||
reel.currentSpeed = val;
|
||||
}
|
||||
|
||||
if (setType == 1)
|
||||
{
|
||||
reel.currentDrag = val;
|
||||
}
|
||||
|
||||
if (saveToPrefs)
|
||||
{
|
||||
// Instance._playerData.SaveEquipment(ItemType.Reel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class FGearData
|
||||
{
|
||||
/// <summary>
|
||||
/// 唯一id
|
||||
/// </summary>
|
||||
public int id;
|
||||
|
||||
/// <summary>
|
||||
/// 配置id
|
||||
/// </summary>
|
||||
public int configId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鱼竿数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FRodData : FGearData
|
||||
{
|
||||
private GameRods _config;
|
||||
|
||||
public GameRods Config
|
||||
{
|
||||
get { return _config ??= GameRods.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 线轴数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FReelData : FGearData
|
||||
{
|
||||
private GameReels _config;
|
||||
|
||||
public GameReels Config
|
||||
{
|
||||
get { return _config ??= GameReels.Get(configId); }
|
||||
}
|
||||
|
||||
public float currentSpeed = 0.5f;
|
||||
|
||||
public float currentDrag = 0.7f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 浮漂数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FBobberData : FGearData
|
||||
{
|
||||
private GameFloats _config;
|
||||
|
||||
public GameFloats Config
|
||||
{
|
||||
get { return _config ??= GameFloats.Get(configId); }
|
||||
}
|
||||
|
||||
public float lastSetGroundValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鱼钩数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FHookData : FGearData
|
||||
{
|
||||
private GameHooks _config;
|
||||
|
||||
public GameHooks Config
|
||||
{
|
||||
get { return _config ??= GameHooks.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鱼饵数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FBaitData : FGearData
|
||||
{
|
||||
private GameBaits _config;
|
||||
|
||||
public GameBaits Config
|
||||
{
|
||||
get { return _config ??= GameBaits.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鱼饵数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FLureData : FGearData
|
||||
{
|
||||
private GameLures _config;
|
||||
|
||||
public GameLures Config
|
||||
{
|
||||
get { return _config ??= GameLures.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 沉子数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FWeightData : FGearData
|
||||
{
|
||||
private GameWeights _config;
|
||||
|
||||
public GameWeights Config
|
||||
{
|
||||
get { return _config ??= GameWeights.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 线数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FLineData : FGearData
|
||||
{
|
||||
private GameLines _config;
|
||||
|
||||
public GameLines Config
|
||||
{
|
||||
get { return _config ??= GameLines.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引线数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FLeaderData : FGearData
|
||||
{
|
||||
private GameLeaders _config;
|
||||
|
||||
public GameLeaders Config
|
||||
{
|
||||
get { return _config ??= GameLeaders.Get(configId); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菲德数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FFeederData : FGearData
|
||||
{
|
||||
private GameFeeders _config;
|
||||
|
||||
public GameFeeders Config
|
||||
{
|
||||
get { return _config ??= GameFeeders.Get(configId); }
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing~/Data/FPlayerData.cs.meta
Normal file
3
Assets/Scripts/Fishing~/Data/FPlayerData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e64ae505cdc344f5acedf6e55ba67a89
|
||||
timeCreated: 1744029443
|
||||
11
Assets/Scripts/Fishing~/Data/RodType.cs
Normal file
11
Assets/Scripts/Fishing~/Data/RodType.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace NBF
|
||||
{
|
||||
public enum GearType
|
||||
{
|
||||
SpinningFloat = 0,
|
||||
Spinning = 1,
|
||||
Feeder = 2,
|
||||
Pole = 4
|
||||
}
|
||||
|
||||
}
|
||||
3
Assets/Scripts/Fishing~/Data/RodType.cs.meta
Normal file
3
Assets/Scripts/Fishing~/Data/RodType.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e9c20d631da449c943671224a8f56f1
|
||||
timeCreated: 1744637252
|
||||
Reference in New Issue
Block a user