测试代码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using FairyGUI;
|
||||
using System.IO;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -6,6 +7,11 @@ namespace NBF.Utils
|
||||
{
|
||||
public static class ItemHelper
|
||||
{
|
||||
public static string GetFullModelPath(this ItemConfig config)
|
||||
{
|
||||
return Path.Combine("gfx", config.Model);
|
||||
}
|
||||
|
||||
public static ItemType GetItemType(this uint id)
|
||||
{
|
||||
return (ItemType)(id / 10000);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d89005a134404b88b748787a74946d20
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public interface IConfigContext
|
||||
{
|
||||
// 定义非泛型接口
|
||||
}
|
||||
|
||||
public class ConfigContext<T> : IConfigContext where T : ConfigBase
|
||||
{
|
||||
private static List<T> _cacheList = new List<T>();
|
||||
|
||||
#region Cache
|
||||
|
||||
public void Association(List<T> list)
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
_cacheList = list;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public int Count()
|
||||
{
|
||||
return _cacheList.Count;
|
||||
}
|
||||
|
||||
public int Count(Func<T, bool> predicate)
|
||||
{
|
||||
return _cacheList.Count(predicate);
|
||||
}
|
||||
|
||||
public T Get(int key)
|
||||
{
|
||||
return First(key);
|
||||
}
|
||||
|
||||
public T Fist()
|
||||
{
|
||||
return _cacheList.First();
|
||||
}
|
||||
|
||||
public T Last()
|
||||
{
|
||||
return _cacheList.Last();
|
||||
}
|
||||
|
||||
public T Fist(Predicate<T> match)
|
||||
{
|
||||
return Get(match);
|
||||
}
|
||||
|
||||
public T Last(Predicate<T> match)
|
||||
{
|
||||
return _cacheList.FindLast(match);
|
||||
}
|
||||
|
||||
public T Get(Predicate<T> match)
|
||||
{
|
||||
return _cacheList.Find(match);
|
||||
}
|
||||
|
||||
public T GetRandom()
|
||||
{
|
||||
Random random = new Random();
|
||||
// 随机从列表中取一个对象
|
||||
return _cacheList[random.Next(_cacheList.Count)];
|
||||
}
|
||||
|
||||
public List<T> GetList()
|
||||
{
|
||||
return _cacheList;
|
||||
}
|
||||
|
||||
public List<T> GetList(Predicate<T> match)
|
||||
{
|
||||
return _cacheList.FindAll(match);
|
||||
}
|
||||
|
||||
private T First(int key)
|
||||
{
|
||||
return _cacheList.Find(t => t.id == key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82dbb868b2724a85aa866e0bf9e88e91
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class Configs
|
||||
{
|
||||
private static readonly Dictionary<Type, IConfigContext> _dictionary = new Dictionary<Type, IConfigContext>();
|
||||
|
||||
static Configs()
|
||||
{
|
||||
}
|
||||
|
||||
public static ConfigContext<T> Table<T>() where T : ConfigBase
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_dictionary.TryGetValue(type, out var context))
|
||||
{
|
||||
return context as ConfigContext<T>;
|
||||
}
|
||||
|
||||
var jsonContext = new ConfigContext<T>();
|
||||
_dictionary[type] = jsonContext;
|
||||
return jsonContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1881c9eee25240ddbaecbf99546a8750
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class TableNameAttribute : Attribute
|
||||
{
|
||||
public string Name;
|
||||
public string Key;
|
||||
|
||||
public TableNameAttribute(string name, string key = "id")
|
||||
{
|
||||
Name = name;
|
||||
Key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 737030131eba4fd6ba6067b47fcae5d3
|
||||
timeCreated: 1744862554
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NBC;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ConfigAssets
|
||||
{
|
||||
private static readonly Type CustomType = typeof(ICustomParse);
|
||||
|
||||
private static List<T> ParseLine<T>(JToken[] arr, TableNameAttribute tableNameAttribute) where T : ConfigBase
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
var type = typeof(T);
|
||||
foreach (var jToken in arr)
|
||||
{
|
||||
T instance = null;
|
||||
try
|
||||
{
|
||||
if (CustomType.IsAssignableFrom(type)) //自定义解析
|
||||
{
|
||||
instance = Activator.CreateInstance<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = jToken.ToObject<T>();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
|
||||
if (instance != null)
|
||||
{
|
||||
var key = jToken[tableNameAttribute.Key].ToInt();
|
||||
if (key < 1)
|
||||
{
|
||||
if (instance.id > 0)
|
||||
{
|
||||
key = instance.id;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (key < 1) continue;
|
||||
if (instance is ICustomParse customParse)
|
||||
{
|
||||
customParse.Parse(jToken);
|
||||
}
|
||||
|
||||
instance.id = key;
|
||||
list.Add(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09494bd809bd47b29be0723c8671afb8
|
||||
timeCreated: 1744898106
|
||||
@@ -1,30 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ConfigAssets : ScriptableObject
|
||||
{
|
||||
// public static string SavePath => $"Assets/ResRaw/Config/ConfigAssets.asset";
|
||||
public static string SavePath => $"Assets/Resources/Config/ConfigAssets.asset";
|
||||
private static ConfigAssets _inst;
|
||||
|
||||
public static ConfigAssets Instance => _inst;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var asset = Resources.Load<ConfigAssets>("config/ConfigAssets");
|
||||
if (asset != null)
|
||||
{
|
||||
asset.AssociationContexts();
|
||||
_inst = asset;
|
||||
}
|
||||
|
||||
// var assetProvider = NBC.Asset.Assets.LoadAsset<ConfigAssets>(SavePath);
|
||||
// if (assetProvider != null && assetProvider.Asset is ConfigAssets asset)
|
||||
// {
|
||||
// asset.AssociationContexts();
|
||||
// _inst = asset;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d8691ef03f74aedb6cfd67e53cf664f
|
||||
timeCreated: 1742999693
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2178333fb882410eb05c0f66a95c8880
|
||||
timeCreated: 1742998269
|
||||
@@ -1,197 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class CfgEditorUtil
|
||||
{
|
||||
[MenuItem("构建/配置表/生成脚本")]
|
||||
public static void CreateScriptableObject()
|
||||
{
|
||||
EditorUtils.GetOrCreateAsset<ConfigAssets>(ConfigAssets.SavePath);
|
||||
GenConfigScripts();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("构建/配置表/导表")]
|
||||
public static void BuildExcel()
|
||||
{
|
||||
ExcelToJsonWindow.GenConfig(false);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("构建/配置表/导多语言")]
|
||||
public static void BuildLanguage()
|
||||
{
|
||||
ExcelToJsonWindow.GenLanguage();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
#region 生成脚本
|
||||
|
||||
private static string GenPath = "Scripts/Configs/Gen";
|
||||
private static string TempPath = "Scripts/Configs/Editor/ConfigWarpTemplate";
|
||||
|
||||
public static void GenConfigScripts()
|
||||
{
|
||||
if (!Directory.Exists($"{Application.dataPath}/{GenPath}"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var types = Reflection.GetAllNonAbstractDerivedTypes<ConfigBase>();
|
||||
Dictionary<Type, string> tableNameAttributes = new Dictionary<Type, string>();
|
||||
foreach (var type in types)
|
||||
{
|
||||
tableNameAttributes[type] = type.Name;
|
||||
}
|
||||
|
||||
// var canGen = CanGen(tableNameAttributes);
|
||||
//
|
||||
// if (!canGen) return;
|
||||
GenParse(tableNameAttributes);
|
||||
GenWarp(tableNameAttributes);
|
||||
// GenBinder(tableNameAttributes);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private static bool CanGen(Dictionary<Type, string> tableNameAttributes)
|
||||
{
|
||||
// return true;
|
||||
string filePath = Path.Combine(Application.dataPath, $"{GenPath}/Warps");
|
||||
if (!Directory.Exists(filePath)) return true;
|
||||
var files = Directory.GetFiles(filePath);
|
||||
List<string> allFileName = new List<string>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (Path.GetExtension(file).ToLower() == ".meta") continue;
|
||||
var fileName = Path.GetFileNameWithoutExtension(file);
|
||||
allFileName.Add(fileName.Replace("Warp", ""));
|
||||
}
|
||||
|
||||
if (allFileName.Count != tableNameAttributes.Count) return true;
|
||||
|
||||
foreach (var type in tableNameAttributes.Keys)
|
||||
{
|
||||
if (!allFileName.Contains(type.Name)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static void GenWarp(Dictionary<Type, string> tableNameAttributes)
|
||||
{
|
||||
// 为何使用生成式,不使用static静态泛型 ? 生成式扩展更强且不会破坏原类的集成结构,父类也不用是泛型类
|
||||
//否则比如 BaseConfig<T> 类型来使用。集成结构会受很大限制,反而没有生成式来的灵活
|
||||
|
||||
string filePath = Path.Combine(Application.dataPath, TempPath);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
// 读取文本内容
|
||||
string fileContent = File.ReadAllText(filePath);
|
||||
var rootPath = $"{Application.dataPath}/{GenPath}/Warps";
|
||||
if (!Directory.Exists(rootPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(rootPath))
|
||||
{
|
||||
Directory.CreateDirectory(rootPath);
|
||||
}
|
||||
|
||||
foreach (var type in tableNameAttributes.Keys)
|
||||
{
|
||||
var content = fileContent.Replace("##NAME##", type.Name);
|
||||
File.WriteAllText($"{rootPath}/{type.Name}Warp.cs", content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("生成代码模板不存在,请检查");
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenParse(Dictionary<Type, string> tableNameAttributes)
|
||||
{
|
||||
if (!Directory.Exists($"{Application.dataPath}/{GenPath}"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CodeWriter codeWriter = new CodeWriter();
|
||||
codeWriter.Writeln("/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/");
|
||||
codeWriter.Writeln();
|
||||
codeWriter.Writeln("using System;");
|
||||
codeWriter.Writeln("using System.Collections.Generic;");
|
||||
codeWriter.Writeln("using System.Reflection;");
|
||||
codeWriter.Writeln("using Newtonsoft.Json.Linq;");
|
||||
codeWriter.Writeln("using UnityEngine;");
|
||||
|
||||
codeWriter.Writeln();
|
||||
codeWriter.Writeln("namespace NBF");
|
||||
|
||||
codeWriter.StartBlock();
|
||||
|
||||
codeWriter.Writeln("public partial class ConfigAssets");
|
||||
codeWriter.StartBlock();
|
||||
|
||||
foreach (var type in tableNameAttributes.Keys)
|
||||
{
|
||||
// codeWriter.Writeln($"[HideInInspector] public List<{type.Name}> {type.Name}Arr;");
|
||||
codeWriter.Writeln($"public List<{type.Name}> {type.Name}Arr;");
|
||||
}
|
||||
|
||||
codeWriter.Writeln();
|
||||
|
||||
codeWriter.Writeln("public void Parse(JToken[] arr, Type type)");
|
||||
codeWriter.StartBlock();
|
||||
codeWriter.Writeln("var tableNameAttribute = type.GetCustomAttribute<TableNameAttribute>();");
|
||||
codeWriter.Writeln("if (tableNameAttribute == null) return;");
|
||||
|
||||
foreach (var type in tableNameAttributes.Keys)
|
||||
{
|
||||
codeWriter.Writeln($"if (type == typeof({type.Name}))");
|
||||
codeWriter.StartBlock();
|
||||
codeWriter.Writeln($"{type.Name}Arr = ParseLine<{type.Name}>(arr, tableNameAttribute);");
|
||||
codeWriter.EndBlock();
|
||||
codeWriter.Writeln();
|
||||
}
|
||||
|
||||
codeWriter.EndBlock();
|
||||
|
||||
codeWriter.Writeln();
|
||||
codeWriter.Writeln("public void AssociationContexts()");
|
||||
codeWriter.StartBlock();
|
||||
|
||||
foreach (var type in tableNameAttributes.Keys)
|
||||
{
|
||||
codeWriter.Writeln($"new ConfigContext<{type.Name}>().Association({type.Name}Arr);");
|
||||
}
|
||||
|
||||
codeWriter.EndBlock();
|
||||
|
||||
|
||||
codeWriter.EndBlock();
|
||||
codeWriter.EndBlock();
|
||||
|
||||
codeWriter.Save($"{Application.dataPath}/{GenPath}/ConfigAssets.Gen.cs");
|
||||
}
|
||||
|
||||
|
||||
private static void WriterCreateParse(CodeWriter codeWriter, Type type)
|
||||
{
|
||||
codeWriter.Writeln($"if (type == typeof({type.Name}))");
|
||||
codeWriter.StartBlock();
|
||||
codeWriter.Writeln($"return CreateParseTableTask<{type.Name}>();");
|
||||
codeWriter.EndBlock();
|
||||
codeWriter.Writeln();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bc0ac74b225496da64195b28ce14cb2
|
||||
timeCreated: 1742998279
|
||||
@@ -1,105 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public interface ICodeWriterConfig
|
||||
{
|
||||
string BlockStart { get; set; }
|
||||
string BlockEnd { get; set; }
|
||||
bool BlockFromNewLine { get; set; }
|
||||
bool UsingTabs { get; set; }
|
||||
string EndOfLine { get; set; }
|
||||
}
|
||||
|
||||
public class DefCSharpCodeWriterConfig : ICodeWriterConfig
|
||||
{
|
||||
public string BlockStart { get; set; } = "{";
|
||||
public string BlockEnd { get; set; } = "}";
|
||||
public bool BlockFromNewLine { get; set; }
|
||||
public bool UsingTabs { get; set; } = true;
|
||||
public string EndOfLine { get; set; }
|
||||
}
|
||||
|
||||
public class CodeWriter
|
||||
{
|
||||
private ICodeWriterConfig _config;
|
||||
|
||||
private StringBuilder _stringBuilder = new StringBuilder();
|
||||
|
||||
private int _nowTabCount;
|
||||
|
||||
public CodeWriter()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public CodeWriter(ICodeWriterConfig config)
|
||||
{
|
||||
Init(config);
|
||||
}
|
||||
|
||||
public void Write(string content)
|
||||
{
|
||||
_stringBuilder.Append(content);
|
||||
}
|
||||
|
||||
public void Writeln()
|
||||
{
|
||||
_stringBuilder.Append(Environment.NewLine);
|
||||
}
|
||||
|
||||
public void Writeln(string str)
|
||||
{
|
||||
_stringBuilder.Append(GetLinePrefix());
|
||||
_stringBuilder.Append(str);
|
||||
_stringBuilder.Append(Environment.NewLine);
|
||||
}
|
||||
|
||||
public void StartBlock()
|
||||
{
|
||||
Writeln(_config.BlockStart);
|
||||
_nowTabCount++;
|
||||
}
|
||||
|
||||
public void EndBlock()
|
||||
{
|
||||
_nowTabCount--;
|
||||
Writeln(_config.BlockEnd);
|
||||
}
|
||||
|
||||
public void Save(string path)
|
||||
{
|
||||
var dirPath = Path.GetDirectoryName(path);
|
||||
if (dirPath != null && !Directory.Exists(dirPath))
|
||||
{
|
||||
Directory.CreateDirectory(dirPath);
|
||||
}
|
||||
|
||||
var content = _stringBuilder.ToString();
|
||||
File.WriteAllText(path, content);
|
||||
}
|
||||
|
||||
#region 内部方法
|
||||
|
||||
private void Init(ICodeWriterConfig config = null)
|
||||
{
|
||||
_config = config ?? new DefCSharpCodeWriterConfig();
|
||||
}
|
||||
|
||||
private string GetLinePrefix()
|
||||
{
|
||||
string ret = string.Empty;
|
||||
if (!_config.UsingTabs) return ret;
|
||||
for (var i = 0; i < _nowTabCount; i++)
|
||||
{
|
||||
ret += "\t";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf1ac73cd67e4bdc9de1a53a13f5b841
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class ##NAME##
|
||||
{
|
||||
private static ConfigContext<##NAME##> _context;
|
||||
|
||||
private static ConfigContext<##NAME##> Context => _context ??= Configs.Table<##NAME##>();
|
||||
|
||||
public static ##NAME## Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static ##NAME## Get(Predicate<##NAME##> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static ##NAME## Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static ##NAME## Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static ##NAME## Fist(Predicate<##NAME##> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static ##NAME## Last(Predicate<##NAME##> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<##NAME##, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<##NAME##> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<##NAME##> GetList(Predicate<##NAME##> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b77eee728204f26bc602016c4a20c86
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8a50bb33d07439e9c7762e17bced2e0
|
||||
timeCreated: 1744862665
|
||||
@@ -1,138 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class JTokenExtends
|
||||
{
|
||||
public static Vector2 ToVector2(this string str, string sp = ",")
|
||||
{
|
||||
Vector2 vector2 = Vector2.zero;
|
||||
var arr = str.Split(sp);
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
float.TryParse(arr[0], out vector2.x);
|
||||
if (arr.Length > 1)
|
||||
{
|
||||
float.TryParse(arr[1], out vector2.y);
|
||||
}
|
||||
}
|
||||
|
||||
return vector2;
|
||||
}
|
||||
|
||||
public static Vector3 ToVector3(this string str, string sp = ",")
|
||||
{
|
||||
Vector3 vector2 = Vector3.zero;
|
||||
var arr = str.Split(sp);
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
float.TryParse(arr[0], out vector2.x);
|
||||
if (arr.Length > 1)
|
||||
{
|
||||
float.TryParse(arr[1], out vector2.y);
|
||||
}
|
||||
|
||||
if (arr.Length > 2)
|
||||
{
|
||||
float.TryParse(arr[2], out vector2.z);
|
||||
}
|
||||
}
|
||||
|
||||
return vector2;
|
||||
}
|
||||
|
||||
public static T[] ToArr<T>(this JToken token, string split = ",") where T : IConvertible
|
||||
{
|
||||
if (token is JArray array)
|
||||
{
|
||||
return array.ToObject<T[]>();
|
||||
}
|
||||
|
||||
if (token != null)
|
||||
{
|
||||
var str = token.ToString();
|
||||
if (string.IsNullOrWhiteSpace(str)) return Array.Empty<T>();
|
||||
|
||||
var arr = str.Split(split);
|
||||
try
|
||||
{
|
||||
return arr.Select(a => (T)Convert.ChangeType(a, typeof(T))).ToArray();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<T>();
|
||||
}
|
||||
|
||||
public static int ToInt(this JToken token)
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (int)token;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static float ToFloat(this JToken token)
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (float)token;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToStr(this JToken token)
|
||||
{
|
||||
if (token != null)
|
||||
{
|
||||
return token.ToString();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static List<T> ToList<T>(this JToken token, string split = ",") where T : IConvertible
|
||||
{
|
||||
if (token is JArray array)
|
||||
{
|
||||
return array.ToObject<List<T>>();
|
||||
}
|
||||
|
||||
if (token != null)
|
||||
{
|
||||
var str = token.ToString();
|
||||
if (string.IsNullOrWhiteSpace(str)) return new List<T>();
|
||||
var arr = str.Split(split);
|
||||
return arr.Select(
|
||||
a => string.IsNullOrWhiteSpace(a) ? default : (T)Convert.ChangeType(a, typeof(T))).ToList();
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d6ce3cc850f41b8ba83653660b928ce
|
||||
timeCreated: 1744862670
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eceaba126fb407583191d01e32bb735
|
||||
timeCreated: 1756050728
|
||||
@@ -1,122 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ConfigAssets
|
||||
{
|
||||
public List<BaitConfig> BaitConfigArr;
|
||||
public List<BobberConfig> BobberConfigArr;
|
||||
public List<FeederConfig> FeederConfigArr;
|
||||
public List<FishAcceptConfig> FishAcceptConfigArr;
|
||||
public List<FishConfig> FishConfigArr;
|
||||
public List<HookConfig> HookConfigArr;
|
||||
public List<LeadersConfig> LeadersConfigArr;
|
||||
public List<LineConfig> LineConfigArr;
|
||||
public List<LureConfig> LureConfigArr;
|
||||
public List<ReelConfig> ReelConfigArr;
|
||||
public List<RingConfig> RingConfigArr;
|
||||
public List<RodConfig> RodConfigArr;
|
||||
public List<UnitConfig> UnitConfigArr;
|
||||
public List<WeightConfig> WeightConfigArr;
|
||||
|
||||
public void Parse(JToken[] arr, Type type)
|
||||
{
|
||||
var tableNameAttribute = type.GetCustomAttribute<TableNameAttribute>();
|
||||
if (tableNameAttribute == null) return;
|
||||
if (type == typeof(BaitConfig))
|
||||
{
|
||||
BaitConfigArr = ParseLine<BaitConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(BobberConfig))
|
||||
{
|
||||
BobberConfigArr = ParseLine<BobberConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(FeederConfig))
|
||||
{
|
||||
FeederConfigArr = ParseLine<FeederConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(FishAcceptConfig))
|
||||
{
|
||||
FishAcceptConfigArr = ParseLine<FishAcceptConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(FishConfig))
|
||||
{
|
||||
FishConfigArr = ParseLine<FishConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(HookConfig))
|
||||
{
|
||||
HookConfigArr = ParseLine<HookConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(LeadersConfig))
|
||||
{
|
||||
LeadersConfigArr = ParseLine<LeadersConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(LineConfig))
|
||||
{
|
||||
LineConfigArr = ParseLine<LineConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(LureConfig))
|
||||
{
|
||||
LureConfigArr = ParseLine<LureConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(ReelConfig))
|
||||
{
|
||||
ReelConfigArr = ParseLine<ReelConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(RingConfig))
|
||||
{
|
||||
RingConfigArr = ParseLine<RingConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(RodConfig))
|
||||
{
|
||||
RodConfigArr = ParseLine<RodConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(UnitConfig))
|
||||
{
|
||||
UnitConfigArr = ParseLine<UnitConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
if (type == typeof(WeightConfig))
|
||||
{
|
||||
WeightConfigArr = ParseLine<WeightConfig>(arr, tableNameAttribute);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void AssociationContexts()
|
||||
{
|
||||
new ConfigContext<BaitConfig>().Association(BaitConfigArr);
|
||||
new ConfigContext<BobberConfig>().Association(BobberConfigArr);
|
||||
new ConfigContext<FeederConfig>().Association(FeederConfigArr);
|
||||
new ConfigContext<FishAcceptConfig>().Association(FishAcceptConfigArr);
|
||||
new ConfigContext<FishConfig>().Association(FishConfigArr);
|
||||
new ConfigContext<HookConfig>().Association(HookConfigArr);
|
||||
new ConfigContext<LeadersConfig>().Association(LeadersConfigArr);
|
||||
new ConfigContext<LineConfig>().Association(LineConfigArr);
|
||||
new ConfigContext<LureConfig>().Association(LureConfigArr);
|
||||
new ConfigContext<ReelConfig>().Association(ReelConfigArr);
|
||||
new ConfigContext<RingConfig>().Association(RingConfigArr);
|
||||
new ConfigContext<RodConfig>().Association(RodConfigArr);
|
||||
new ConfigContext<UnitConfig>().Association(UnitConfigArr);
|
||||
new ConfigContext<WeightConfig>().Association(WeightConfigArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd9bbc8f86e64a928533f493e39813ed
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98e70a75b52b4728aec1e5b7f506695c
|
||||
timeCreated: 1756050753
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class BaitConfig
|
||||
{
|
||||
private static ConfigContext<BaitConfig> _context;
|
||||
|
||||
private static ConfigContext<BaitConfig> Context => _context ??= Configs.Table<BaitConfig>();
|
||||
|
||||
public static BaitConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static BaitConfig Get(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static BaitConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static BaitConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static BaitConfig Fist(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static BaitConfig Last(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<BaitConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<BaitConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<BaitConfig> GetList(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c6bdb0bae4da2a4da6aacaf58a1abc0
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class BobberConfig
|
||||
{
|
||||
private static ConfigContext<BobberConfig> _context;
|
||||
|
||||
private static ConfigContext<BobberConfig> Context => _context ??= Configs.Table<BobberConfig>();
|
||||
|
||||
public static BobberConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static BobberConfig Get(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static BobberConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static BobberConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static BobberConfig Fist(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static BobberConfig Last(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<BobberConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<BobberConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<BobberConfig> GetList(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99b64c24f2bad454086ac41dd6aa7ffc
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class FeederConfig
|
||||
{
|
||||
private static ConfigContext<FeederConfig> _context;
|
||||
|
||||
private static ConfigContext<FeederConfig> Context => _context ??= Configs.Table<FeederConfig>();
|
||||
|
||||
public static FeederConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static FeederConfig Get(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static FeederConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static FeederConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static FeederConfig Fist(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static FeederConfig Last(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<FeederConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<FeederConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<FeederConfig> GetList(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc082eda2a5880148843ce9c21ed4eed
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class FishAcceptConfig
|
||||
{
|
||||
private static ConfigContext<FishAcceptConfig> _context;
|
||||
|
||||
private static ConfigContext<FishAcceptConfig> Context => _context ??= Configs.Table<FishAcceptConfig>();
|
||||
|
||||
public static FishAcceptConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static FishAcceptConfig Get(Predicate<FishAcceptConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static FishAcceptConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static FishAcceptConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static FishAcceptConfig Fist(Predicate<FishAcceptConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static FishAcceptConfig Last(Predicate<FishAcceptConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<FishAcceptConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<FishAcceptConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<FishAcceptConfig> GetList(Predicate<FishAcceptConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23d45122e487d8f439bf063a4df7a4b7
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class FishConfig
|
||||
{
|
||||
private static ConfigContext<FishConfig> _context;
|
||||
|
||||
private static ConfigContext<FishConfig> Context => _context ??= Configs.Table<FishConfig>();
|
||||
|
||||
public static FishConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static FishConfig Get(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static FishConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static FishConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static FishConfig Fist(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static FishConfig Last(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<FishConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<FishConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<FishConfig> GetList(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d60d97e94b1432c4e985a5469fd01409
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class HookConfig
|
||||
{
|
||||
private static ConfigContext<HookConfig> _context;
|
||||
|
||||
private static ConfigContext<HookConfig> Context => _context ??= Configs.Table<HookConfig>();
|
||||
|
||||
public static HookConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static HookConfig Get(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static HookConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static HookConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static HookConfig Fist(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static HookConfig Last(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<HookConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<HookConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<HookConfig> GetList(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc38b93ab46f1bd4a83f81f1cd3b3e4c
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class LeadersConfig
|
||||
{
|
||||
private static ConfigContext<LeadersConfig> _context;
|
||||
|
||||
private static ConfigContext<LeadersConfig> Context => _context ??= Configs.Table<LeadersConfig>();
|
||||
|
||||
public static LeadersConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static LeadersConfig Get(Predicate<LeadersConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static LeadersConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static LeadersConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static LeadersConfig Fist(Predicate<LeadersConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static LeadersConfig Last(Predicate<LeadersConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<LeadersConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<LeadersConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<LeadersConfig> GetList(Predicate<LeadersConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7911fb1cf4470014eadb4d9db5db5861
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class LineConfig
|
||||
{
|
||||
private static ConfigContext<LineConfig> _context;
|
||||
|
||||
private static ConfigContext<LineConfig> Context => _context ??= Configs.Table<LineConfig>();
|
||||
|
||||
public static LineConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static LineConfig Get(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static LineConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static LineConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static LineConfig Fist(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static LineConfig Last(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<LineConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<LineConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<LineConfig> GetList(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1acb019fe35da324cb5a26e45c54532d
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class LureConfig
|
||||
{
|
||||
private static ConfigContext<LureConfig> _context;
|
||||
|
||||
private static ConfigContext<LureConfig> Context => _context ??= Configs.Table<LureConfig>();
|
||||
|
||||
public static LureConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static LureConfig Get(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static LureConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static LureConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static LureConfig Fist(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static LureConfig Last(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<LureConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<LureConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<LureConfig> GetList(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74aae733a506d0840a1a7cc2623ed5fd
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class ReelConfig
|
||||
{
|
||||
private static ConfigContext<ReelConfig> _context;
|
||||
|
||||
private static ConfigContext<ReelConfig> Context => _context ??= Configs.Table<ReelConfig>();
|
||||
|
||||
public static ReelConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static ReelConfig Get(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static ReelConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static ReelConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static ReelConfig Fist(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static ReelConfig Last(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<ReelConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<ReelConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<ReelConfig> GetList(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bfa9f163eb97be418e04f1f62c607de
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class RingConfig
|
||||
{
|
||||
private static ConfigContext<RingConfig> _context;
|
||||
|
||||
private static ConfigContext<RingConfig> Context => _context ??= Configs.Table<RingConfig>();
|
||||
|
||||
public static RingConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static RingConfig Get(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static RingConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static RingConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static RingConfig Fist(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static RingConfig Last(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<RingConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<RingConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<RingConfig> GetList(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a52a98969f4fae44ba19533cb1ae552e
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class RodConfig
|
||||
{
|
||||
private static ConfigContext<RodConfig> _context;
|
||||
|
||||
private static ConfigContext<RodConfig> Context => _context ??= Configs.Table<RodConfig>();
|
||||
|
||||
public static RodConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static RodConfig Get(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static RodConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static RodConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static RodConfig Fist(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static RodConfig Last(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<RodConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<RodConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<RodConfig> GetList(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81f057dddf36a734ead19cd98e19a2e0
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class UnitConfig
|
||||
{
|
||||
private static ConfigContext<UnitConfig> _context;
|
||||
|
||||
private static ConfigContext<UnitConfig> Context => _context ??= Configs.Table<UnitConfig>();
|
||||
|
||||
public static UnitConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static UnitConfig Get(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static UnitConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static UnitConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static UnitConfig Fist(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static UnitConfig Last(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<UnitConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<UnitConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<UnitConfig> GetList(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69acf2fddccdd7b4fae3ad883cbc50ec
|
||||
@@ -1,65 +0,0 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public partial class WeightConfig
|
||||
{
|
||||
private static ConfigContext<WeightConfig> _context;
|
||||
|
||||
private static ConfigContext<WeightConfig> Context => _context ??= Configs.Table<WeightConfig>();
|
||||
|
||||
public static WeightConfig Get(int key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static WeightConfig Get(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static WeightConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static WeightConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static WeightConfig Fist(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static WeightConfig Last(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<WeightConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
|
||||
public static List<WeightConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<WeightConfig> GetList(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43244884876723947bd6574d57b2349c
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fbbf78150ef486581fecb379fc3b1cd
|
||||
timeCreated: 1742998650
|
||||
@@ -1,137 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameBaits")]
|
||||
public partial class BaitConfig : ConfigGearBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Natural = 0,
|
||||
Spinning = 1
|
||||
}
|
||||
|
||||
|
||||
public Type type;
|
||||
|
||||
public FishSpecies[] acceptFish;
|
||||
|
||||
public Vector2 weightFishAccept = new Vector2(0f, 3f);
|
||||
|
||||
|
||||
public float weight = 10f;
|
||||
|
||||
public float lenght;
|
||||
|
||||
public int amount = 1;
|
||||
|
||||
|
||||
public int Level = 1;
|
||||
|
||||
private Vector2 startedbaitValues;
|
||||
|
||||
|
||||
public virtual bool CheckIsFishAccept(FishSpecies fishSpecies, float fishWeight = 0f)
|
||||
{
|
||||
var fish = FishConfig.Get(t => t.speciesName == fishSpecies);
|
||||
if (fish == null) return false;
|
||||
if (fish.type == FishConfig.Type.Predator && type == Type.Spinning)
|
||||
{
|
||||
Vector2 vector = weightFishAccept;
|
||||
Debug.Log("Startowa wartosc przynety:" + vector.ToString());
|
||||
vector = startedbaitValues;
|
||||
Debug.Log("Kolejna wartosc przynety 1:" + vector.ToString());
|
||||
Vector2 vector2 = new Vector2(0f, 0f);
|
||||
if (startedbaitValues == vector2)
|
||||
{
|
||||
if (weightFishAccept.x > 0.01f && weightFishAccept.x <= 2.5f)
|
||||
{
|
||||
weightFishAccept.x = 0.01f;
|
||||
}
|
||||
else if (weightFishAccept.x > 2.5f && weightFishAccept.x <= 9.2f)
|
||||
{
|
||||
weightFishAccept.x = 2.5f;
|
||||
}
|
||||
else if (weightFishAccept.x > 9.2f && weightFishAccept.x <= 20f)
|
||||
{
|
||||
weightFishAccept.x = 8f;
|
||||
}
|
||||
else if (weightFishAccept.x > 20f && weightFishAccept.x <= 50f)
|
||||
{
|
||||
weightFishAccept.x = 14f;
|
||||
}
|
||||
else if (weightFishAccept.x > 50f && weightFishAccept.x <= 700f)
|
||||
{
|
||||
weightFishAccept.x = 22f;
|
||||
}
|
||||
else if (weightFishAccept.x > 700f)
|
||||
{
|
||||
weightFishAccept.x = 150f;
|
||||
}
|
||||
|
||||
if (weightFishAccept.y > 0.1f && weightFishAccept.y <= 3f)
|
||||
{
|
||||
weightFishAccept.y = 3f;
|
||||
}
|
||||
else if (weightFishAccept.y > 3f && weightFishAccept.y <= 9f)
|
||||
{
|
||||
weightFishAccept.y = 12f;
|
||||
}
|
||||
else if (weightFishAccept.y > 9f && weightFishAccept.y <= 24f)
|
||||
{
|
||||
weightFishAccept.y = 60f;
|
||||
}
|
||||
else if (weightFishAccept.y > 24f && weightFishAccept.y <= 50f)
|
||||
{
|
||||
weightFishAccept.y = 120f;
|
||||
}
|
||||
else if (weightFishAccept.y > 50f && weightFishAccept.y <= 105f)
|
||||
{
|
||||
weightFishAccept.y = 350f;
|
||||
}
|
||||
else if (weightFishAccept.y > 105f && weightFishAccept.y <= 170f)
|
||||
{
|
||||
weightFishAccept.y = 650f;
|
||||
}
|
||||
else if (weightFishAccept.y > 170f && weightFishAccept.y <= 500f)
|
||||
{
|
||||
weightFishAccept.y = 900f;
|
||||
}
|
||||
else if (weightFishAccept.y > 500f)
|
||||
{
|
||||
weightFishAccept.y = 1800f;
|
||||
}
|
||||
|
||||
startedbaitValues = weightFishAccept;
|
||||
vector = startedbaitValues;
|
||||
Debug.Log("Kolejna wartosc przynety: 2" + vector.ToString());
|
||||
}
|
||||
|
||||
if (fishWeight >= weightFishAccept.x && fishWeight <= weightFishAccept.y)
|
||||
{
|
||||
vector = weightFishAccept;
|
||||
Debug.Log("Fish accept lure: " + vector.ToString() + " weight:" + fishWeight);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (fish.type == FishConfig.Type.WhiteFish && type == Type.Natural)
|
||||
{
|
||||
if (acceptFish.Contains(fishSpecies))
|
||||
{
|
||||
Debug.Log("Fish accept bait weight:" + fishWeight);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (fish.type == FishConfig.Type.Predator && type == Type.Natural &&
|
||||
acceptFish.Contains(fishSpecies))
|
||||
{
|
||||
Debug.Log("Fish accept bait predator weight:" + fishWeight);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29ac65179e8d469d96caa04ce15021d6
|
||||
timeCreated: 1742999023
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameFloats")]
|
||||
public partial class BobberConfig : ConfigGearBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Slider = 0,
|
||||
Waggler = 1,
|
||||
PoleFloats = 2,
|
||||
Sport = 3,
|
||||
Ball = 4,
|
||||
Sinker = 5
|
||||
}
|
||||
|
||||
|
||||
public Type type;
|
||||
|
||||
public float weight = 10f;
|
||||
|
||||
public float displacement = 10f;
|
||||
|
||||
public bool isNightLight;
|
||||
|
||||
public int Level = 1;
|
||||
|
||||
public int amount = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6297ba097dac45eb8f14f55dc5ad7d7b
|
||||
timeCreated: 1742999241
|
||||
@@ -1,68 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f43c20e40ae42239e4381c12ad7cc00
|
||||
timeCreated: 1756823027
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public interface IConfigJsonParse
|
||||
{
|
||||
void Parse(JToken row);
|
||||
}
|
||||
|
||||
public interface ICustomParse
|
||||
{
|
||||
void Parse(JToken row);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class ConfigBase
|
||||
{
|
||||
public string name;
|
||||
|
||||
public int id;
|
||||
}
|
||||
|
||||
public abstract class ConfigGearBase : ConfigBase
|
||||
{
|
||||
public string modelPath = "Models/Rods/";
|
||||
|
||||
protected virtual string ModelRoot => "gfx/";
|
||||
|
||||
/// <summary>
|
||||
/// 所属的组
|
||||
/// </summary>
|
||||
public int group;
|
||||
|
||||
public GameObject GetModelPrefab()
|
||||
{
|
||||
return Resources.Load(ModelRoot + modelPath) as GameObject;
|
||||
}
|
||||
|
||||
public GameObject Instantiate(Transform parent)
|
||||
{
|
||||
return Object.Instantiate(GetModelPrefab(), Vector3.zero, Quaternion.identity, parent);
|
||||
}
|
||||
|
||||
public GameObject Instantiate(Transform parent, Vector3 position,
|
||||
Quaternion rotation)
|
||||
{
|
||||
return Object.Instantiate(GetModelPrefab(), position, rotation, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfb754c68ea2417685d3e29804c996fa
|
||||
timeCreated: 1742998658
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameFeeders")]
|
||||
public partial class FeederConfig : ConfigGearBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Feeder = 0
|
||||
}
|
||||
|
||||
public Type type;
|
||||
|
||||
public float weight = 10f;
|
||||
|
||||
public float capacity = 10f;
|
||||
|
||||
public int Level = 1;
|
||||
|
||||
public int amount = 1;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a3acf5935cc49be8a1e655250ea28e9
|
||||
timeCreated: 1742999291
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameFishAccepts")]
|
||||
public partial class FishAcceptConfig : ConfigBase
|
||||
{
|
||||
public int bait;
|
||||
|
||||
public float min;
|
||||
|
||||
public float max;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 315e92a457a44e67a23cc79710bebdb6
|
||||
timeCreated: 1744862496
|
||||
@@ -1,134 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public class AcceptFishBait
|
||||
{
|
||||
public string baitName;
|
||||
|
||||
public int baitId;
|
||||
|
||||
public float min;
|
||||
|
||||
public float max;
|
||||
}
|
||||
|
||||
[TableName("gameFish")]
|
||||
public partial class FishConfig : ConfigBase
|
||||
{
|
||||
public static FishConfig Get(FishSpecies fishSpecies)
|
||||
{
|
||||
return Get(t => t.speciesName == fishSpecies);
|
||||
}
|
||||
|
||||
public enum Type
|
||||
{
|
||||
WhiteFish = 0,
|
||||
Predator = 1
|
||||
}
|
||||
|
||||
public FishSpecies speciesName;
|
||||
|
||||
public bool isEnabled = true;
|
||||
|
||||
public Type type = Type.Predator;
|
||||
|
||||
public float maxWeight = 10f;
|
||||
|
||||
public float speciesCoins = 4f;
|
||||
|
||||
public int rankingPoint = 1;
|
||||
|
||||
public string[] modelPath;
|
||||
|
||||
public string[] imagePath;
|
||||
|
||||
public string[] modelTrophyPath;
|
||||
|
||||
public Vector2[] weightLenghtValues;
|
||||
|
||||
public AnimationCurve weightLengthCurve;
|
||||
|
||||
public List<AcceptFishBait> acceptFishBaits;
|
||||
|
||||
public List<AcceptFishBait> acceptFishLures;
|
||||
|
||||
public Sprite GetIconImage(int index)
|
||||
{
|
||||
return Resources.Load<Sprite>("Icons/Fish/" + imagePath[index]);
|
||||
}
|
||||
|
||||
public float ConvertWeightFishToLength(float weight)
|
||||
{
|
||||
// return FishWeightToLength.Instance.ConvertWeightFishToLength(speciesName, weight);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void SetupCurvesWeight()
|
||||
{
|
||||
weightLengthCurve.keys = null;
|
||||
for (int i = 0; i < weightLenghtValues.Length; i++)
|
||||
{
|
||||
weightLengthCurve.AddKey(weightLenghtValues[i].x, weightLenghtValues[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetFishScale(float weight)
|
||||
{
|
||||
// if (!FishWeightToLength.Instance)
|
||||
// {
|
||||
// return Vector3.one;
|
||||
// }
|
||||
//
|
||||
// var p = FishWeightToLength.Instance.ConvertWeightFishToLength(speciesName, weight);
|
||||
// float num = FishWeightToLength.Instance.ConvertWeightFishToLength(speciesName, weight) * 0.0185f;
|
||||
// return Vector3.one * num;
|
||||
return Vector3.one;
|
||||
}
|
||||
|
||||
public GameObject GetModelPrefab(string _modelPath)
|
||||
{
|
||||
return Resources.Load("GameItemsPrefabs/Fish/" + _modelPath) as GameObject;
|
||||
}
|
||||
|
||||
public GameObject GetTrophyModelPrefab(float weight)
|
||||
{
|
||||
if (weight > maxWeight)
|
||||
{
|
||||
weight = maxWeight;
|
||||
}
|
||||
|
||||
float num = maxWeight / (float)modelTrophyPath.Length;
|
||||
int num2 = (int)(weight / num);
|
||||
if (num2 >= modelTrophyPath.Length)
|
||||
{
|
||||
num2 = modelTrophyPath.Length - 1;
|
||||
}
|
||||
|
||||
return Resources.Load("GameItemsPrefabs/Fish Trophies/" + modelTrophyPath[num2]) as GameObject;
|
||||
}
|
||||
|
||||
public GameObject GetFishModel(float weight)
|
||||
{
|
||||
if (weight > maxWeight)
|
||||
{
|
||||
weight = maxWeight;
|
||||
}
|
||||
|
||||
float num = maxWeight / (float)modelPath.Length;
|
||||
int num2 = (int)(weight / num);
|
||||
if (num2 >= modelPath.Length)
|
||||
{
|
||||
num2 = modelPath.Length - 1;
|
||||
}
|
||||
|
||||
return GetModelPrefab(modelPath[num2]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 036e4898008747fda0a473707565667b
|
||||
timeCreated: 1742999445
|
||||
@@ -1,167 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameHooks")]
|
||||
public partial class HookConfig : ConfigGearBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Aberdeen = 0,
|
||||
Bait = 1,
|
||||
Circle = 2,
|
||||
Treble = 3,
|
||||
Octopus = 4,
|
||||
Carp = 5,
|
||||
LiveBait = 6,
|
||||
WideGap = 7
|
||||
}
|
||||
|
||||
public enum Zadzior
|
||||
{
|
||||
None = 0,
|
||||
Barbless = 1
|
||||
}
|
||||
|
||||
public enum Size
|
||||
{
|
||||
_16 = 0,
|
||||
_14 = 1,
|
||||
_12 = 2,
|
||||
_10 = 3,
|
||||
_9 = 4,
|
||||
_8 = 5,
|
||||
_7 = 6,
|
||||
_6 = 7,
|
||||
_5 = 8,
|
||||
_4 = 9,
|
||||
_3 = 10,
|
||||
_2 = 11,
|
||||
_1 = 12,
|
||||
_1x0 = 13,
|
||||
_2x0 = 14,
|
||||
_3x0 = 15,
|
||||
_4x0 = 16,
|
||||
_5x0 = 17,
|
||||
_6x0 = 18,
|
||||
_7x0 = 19,
|
||||
_8x0 = 20,
|
||||
_9x0 = 21,
|
||||
_10x0 = 22,
|
||||
_11x0 = 23,
|
||||
_12x0 = 24,
|
||||
_13x0 = 25,
|
||||
_14x0 = 26
|
||||
}
|
||||
|
||||
public string color = "Nickel";
|
||||
|
||||
public Type type;
|
||||
|
||||
public Zadzior zadzior;
|
||||
|
||||
public Size size;
|
||||
|
||||
public int amount = 1;
|
||||
|
||||
public int Level = 1;
|
||||
|
||||
|
||||
public string GetSizetext()
|
||||
{
|
||||
return size.ToString().Replace("_", "#").Replace("x", "/");
|
||||
}
|
||||
|
||||
public Vector2 GetFishAcceptWeightBySize()
|
||||
{
|
||||
Vector2 result = Vector2.zero;
|
||||
switch (size)
|
||||
{
|
||||
case Size._16:
|
||||
result = new Vector2(0f, 3.5f);
|
||||
break;
|
||||
case Size._14:
|
||||
result = new Vector2(0.4f, 5.3f);
|
||||
break;
|
||||
case Size._12:
|
||||
result = new Vector2(0.5f, 7.4f);
|
||||
break;
|
||||
case Size._10:
|
||||
result = new Vector2(0.7f, 10.3f);
|
||||
break;
|
||||
case Size._9:
|
||||
result = new Vector2(1f, 14.4f);
|
||||
break;
|
||||
case Size._8:
|
||||
result = new Vector2(1.4f, 20.2f);
|
||||
break;
|
||||
case Size._7:
|
||||
result = new Vector2(1.6f, 26.2f);
|
||||
break;
|
||||
case Size._6:
|
||||
result = new Vector2(1.8f, 31.5f);
|
||||
break;
|
||||
case Size._5:
|
||||
result = new Vector2(2.2f, 34.6f);
|
||||
break;
|
||||
case Size._4:
|
||||
result = new Vector2(2.4f, 45f);
|
||||
break;
|
||||
case Size._3:
|
||||
result = new Vector2(3.1f, 58.5f);
|
||||
break;
|
||||
case Size._2:
|
||||
result = new Vector2(4.1f, 81.9f);
|
||||
break;
|
||||
case Size._1:
|
||||
result = new Vector2(5.7f, 114.6f);
|
||||
break;
|
||||
case Size._1x0:
|
||||
result = new Vector2(9.2f, 160.5f);
|
||||
break;
|
||||
case Size._2x0:
|
||||
result = new Vector2(12.8f, 216.7f);
|
||||
break;
|
||||
case Size._3x0:
|
||||
result = new Vector2(17.3f, 292.5f);
|
||||
break;
|
||||
case Size._4x0:
|
||||
result = new Vector2(23.4f, 394.9f);
|
||||
break;
|
||||
case Size._5x0:
|
||||
result = new Vector2(31.6f, 533.1f);
|
||||
break;
|
||||
case Size._6x0:
|
||||
result = new Vector2(42.6f, 693f);
|
||||
break;
|
||||
case Size._7x0:
|
||||
result = new Vector2(55.4f, 935f);
|
||||
break;
|
||||
case Size._8x0:
|
||||
result = new Vector2(74.8f, 1122f);
|
||||
break;
|
||||
case Size._9x0:
|
||||
result = new Vector2(89f, 1342f);
|
||||
break;
|
||||
case Size._10x0:
|
||||
result = new Vector2(107f, 1616f);
|
||||
break;
|
||||
case Size._11x0:
|
||||
result = new Vector2(129f, 1940f);
|
||||
break;
|
||||
case Size._12x0:
|
||||
result = new Vector2(155f, 2328f);
|
||||
break;
|
||||
case Size._13x0:
|
||||
result = new Vector2(186f, 2793f);
|
||||
break;
|
||||
case Size._14x0:
|
||||
result = new Vector2(223f, 3352f);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 163f314510a24a43b7f86e22854cde3b
|
||||
timeCreated: 1742999185
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameLeaders")]
|
||||
public partial class LeadersConfig : ConfigGearBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Mono = 0,
|
||||
Wire = 1,
|
||||
Steel = 2,
|
||||
Titanium = 3
|
||||
}
|
||||
|
||||
public Type type;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a5ae0258ce84be1b6b2c2cb6a9921f9
|
||||
timeCreated: 1742998962
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameLines")]
|
||||
public partial class LineConfig : ConfigGearBase
|
||||
{
|
||||
protected override string ModelRoot => "GameItemsPrefabs/";
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Mono = 0,
|
||||
Braid = 1,
|
||||
Fluro = 2
|
||||
}
|
||||
|
||||
public Type type;
|
||||
|
||||
public int length = 125;
|
||||
|
||||
public float strength = 1f;
|
||||
|
||||
public float size = 0.12f;
|
||||
|
||||
public int Level = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f09d37212e24ee2bb9f0b99ca69df42
|
||||
timeCreated: 1742998906
|
||||
@@ -1,123 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameLures")]
|
||||
public partial class LureConfig : ConfigGearBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Natural = 0,
|
||||
Spinning = 1
|
||||
}
|
||||
|
||||
|
||||
public Type type;
|
||||
|
||||
public FishSpecies[] acceptFish;
|
||||
|
||||
public Vector2 weightFishAccept = new Vector2(0f, 3f);
|
||||
|
||||
public float weight = 10f;
|
||||
|
||||
public float lenght;
|
||||
|
||||
public int amount = 1;
|
||||
|
||||
public int Level = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 配的鱼钩
|
||||
/// </summary>
|
||||
public int[] hook;
|
||||
|
||||
private Vector2 startedbaitValues;
|
||||
|
||||
private Vector2 _startedbaitValues;
|
||||
|
||||
public bool CheckIsFishAccept(FishSpecies fishSpecies, float fishWeight = 0)
|
||||
{
|
||||
if (FishConfig.Get(fishSpecies).type == FishConfig.Type.Predator)
|
||||
{
|
||||
Vector2 vector = weightFishAccept;
|
||||
Debug.Log("诱饵的初始值:" + vector.ToString());
|
||||
vector = _startedbaitValues;
|
||||
Debug.Log("下一个诱饵值 1:" + vector.ToString());
|
||||
Vector2 vector2 = new Vector2(0f, 0f);
|
||||
if (_startedbaitValues == vector2)
|
||||
{
|
||||
if (weightFishAccept.x > 0.01f && weightFishAccept.x <= 2.5f)
|
||||
{
|
||||
weightFishAccept.x = 0.01f;
|
||||
}
|
||||
else if (weightFishAccept.x > 2.5f && weightFishAccept.x <= 9.2f)
|
||||
{
|
||||
weightFishAccept.x = 2.5f;
|
||||
}
|
||||
else if (weightFishAccept.x > 9.2f && weightFishAccept.x <= 20f)
|
||||
{
|
||||
weightFishAccept.x = 8f;
|
||||
}
|
||||
else if (weightFishAccept.x > 20f && weightFishAccept.x <= 50f)
|
||||
{
|
||||
weightFishAccept.x = 14f;
|
||||
}
|
||||
else if (weightFishAccept.x > 50f && weightFishAccept.x <= 700f)
|
||||
{
|
||||
weightFishAccept.x = 22f;
|
||||
}
|
||||
else if (weightFishAccept.x > 700f)
|
||||
{
|
||||
weightFishAccept.x = 150f;
|
||||
}
|
||||
|
||||
if (weightFishAccept.y > 0.1f && weightFishAccept.y <= 3f)
|
||||
{
|
||||
weightFishAccept.y = 3f;
|
||||
}
|
||||
else if (weightFishAccept.y > 3f && weightFishAccept.y <= 9f)
|
||||
{
|
||||
weightFishAccept.y = 12f;
|
||||
}
|
||||
else if (weightFishAccept.y > 9f && weightFishAccept.y <= 24f)
|
||||
{
|
||||
weightFishAccept.y = 60f;
|
||||
}
|
||||
else if (weightFishAccept.y > 24f && weightFishAccept.y <= 50f)
|
||||
{
|
||||
weightFishAccept.y = 120f;
|
||||
}
|
||||
else if (weightFishAccept.y > 50f && weightFishAccept.y <= 105f)
|
||||
{
|
||||
weightFishAccept.y = 350f;
|
||||
}
|
||||
else if (weightFishAccept.y > 105f && weightFishAccept.y <= 170f)
|
||||
{
|
||||
weightFishAccept.y = 650f;
|
||||
}
|
||||
else if (weightFishAccept.y > 170f && weightFishAccept.y <= 500f)
|
||||
{
|
||||
weightFishAccept.y = 900f;
|
||||
}
|
||||
else if (weightFishAccept.y > 500f)
|
||||
{
|
||||
weightFishAccept.y = 1800f;
|
||||
}
|
||||
|
||||
_startedbaitValues = weightFishAccept;
|
||||
vector = _startedbaitValues;
|
||||
Debug.Log("另一个有价值的诱饵: 2" + vector.ToString());
|
||||
}
|
||||
|
||||
if (fishWeight >= weightFishAccept.x && fishWeight <= weightFishAccept.y)
|
||||
{
|
||||
vector = weightFishAccept;
|
||||
Debug.Log("Fish accept lure: " + vector.ToString() + " weight:" + fishWeight);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 184995816e1944d2afc02384ef109693
|
||||
timeCreated: 1744898827
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameReels")]
|
||||
public partial class ReelConfig : ConfigGearBase
|
||||
{
|
||||
// protected override string ModelRoot => "GameItemsPrefabs/";
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Universal = 0,
|
||||
Spinning = 1,
|
||||
Casting = 2,
|
||||
Feeder = 3
|
||||
}
|
||||
|
||||
|
||||
public Type type;
|
||||
|
||||
public float strength = 1f;
|
||||
|
||||
public Vector2 gearRatio;
|
||||
|
||||
public int size = 2000;
|
||||
|
||||
public int Level = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13045659d27f4ee89aab30efb1740215
|
||||
timeCreated: 1742998847
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameRings")]
|
||||
public partial class RingConfig : ConfigGearBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15f2ba6ac6404e9390d9cc2604f2016c
|
||||
timeCreated: 1744861381
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameRods")]
|
||||
public partial class RodConfig : ConfigGearBase
|
||||
{
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Universal = 0,
|
||||
Tele = 1,
|
||||
SpinningFloat = 2,
|
||||
Spinning = 3,
|
||||
}
|
||||
|
||||
public enum Action
|
||||
{
|
||||
Slow = 0,
|
||||
Medium = 1,
|
||||
Fast = 2
|
||||
}
|
||||
|
||||
|
||||
public Type type;
|
||||
|
||||
public string length;
|
||||
|
||||
public string weight;
|
||||
|
||||
public float strength = 2f;
|
||||
|
||||
public int maxRange = 15;
|
||||
|
||||
/// <summary>
|
||||
/// 使用的圈id
|
||||
/// </summary>
|
||||
public int ring;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01b7a315690b4a2d8f82aec56a3a3971
|
||||
timeCreated: 1742998702
|
||||
@@ -1,31 +0,0 @@
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameUnit")]
|
||||
public partial class UnitConfig : ConfigBase
|
||||
{
|
||||
public UnitType Type;
|
||||
}
|
||||
|
||||
public enum UnitType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家
|
||||
/// </summary>
|
||||
Player = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 鱼
|
||||
/// </summary>
|
||||
Fish = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 船
|
||||
/// </summary>
|
||||
Boat = 3,
|
||||
|
||||
/// <summary>
|
||||
/// 车
|
||||
/// </summary>
|
||||
Car = 4,
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 956ed7b067744c369fcff9a8baef77ee
|
||||
timeCreated: 1756049614
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[TableName("gameWeights")]
|
||||
public partial class WeightConfig : ConfigGearBase
|
||||
{
|
||||
protected override string ModelRoot => "GameItemsPrefabs/";
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Ball = 0,
|
||||
Teardrop = 1,
|
||||
Olive = 2
|
||||
}
|
||||
|
||||
public Type type;
|
||||
|
||||
public float weight = 0.1f;
|
||||
|
||||
public int Level = 1;
|
||||
|
||||
public int amount = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bfe88a3b2474031aa65c995baebf6f6
|
||||
timeCreated: 1742999355
|
||||
@@ -1,9 +1,17 @@
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using NBF.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Fishing2
|
||||
{
|
||||
public static class PrefabsHelper
|
||||
{
|
||||
private static GameObject LoadPrefab(string path, Transform parent = null)
|
||||
{
|
||||
var prefab = Resources.Load<GameObject>(path);
|
||||
return parent == null ? Object.Instantiate(prefab) : Object.Instantiate(prefab, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建角色预制体
|
||||
/// </summary>
|
||||
@@ -11,15 +19,23 @@ namespace NBF.Fishing2
|
||||
/// <returns></returns>
|
||||
public static GameObject CreatePlayer(Transform parent)
|
||||
{
|
||||
var model = Resources.Load<GameObject>("Prefabs/Player/Human_Male");
|
||||
return Object.Instantiate(model, parent);
|
||||
var model = LoadPrefab("Prefabs/Player/Human_Male", parent);
|
||||
return model;
|
||||
}
|
||||
|
||||
public static GameObject CreatePrefab(string path)
|
||||
/// <summary>
|
||||
/// 创建物品预制体
|
||||
/// </summary>
|
||||
/// <param name="itemInfo"></param>
|
||||
/// <param name="isPreview">是否预览模式</param>
|
||||
/// <returns></returns>
|
||||
public static GameObject CreateItem(ItemInfo itemInfo, bool isPreview = false)
|
||||
{
|
||||
//Assets/Resources/gfx/reels/syberia/spin_5002/spin_5002.prefab
|
||||
var model = Resources.Load<GameObject>(PathHelper.GetFullPath(path));
|
||||
return Object.Instantiate(model);
|
||||
//创建主物体
|
||||
var mainObject = LoadPrefab(itemInfo.Config.GetFullModelPath());
|
||||
//创建配件
|
||||
|
||||
return mainObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Assets/Scripts/ThirdParty/PhysicsTools/Rope.cs
vendored
33
Assets/Scripts/ThirdParty/PhysicsTools/Rope.cs
vendored
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
// using UltimateWater;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
@@ -535,9 +534,11 @@ namespace PhysicsTools
|
||||
float num3 = 1f;
|
||||
int num4 = lstSegments.Count;
|
||||
// if (num4 > 30 && GameController.Instance.useFastRopeDraw)
|
||||
// {
|
||||
// num4 = 30;
|
||||
// }
|
||||
if (num4 > 30)
|
||||
{
|
||||
num4 = 30;
|
||||
}
|
||||
|
||||
List<PosOri> list2 = new List<PosOri>();
|
||||
int num5 = 0;
|
||||
if (lstSegments.Count > 0)
|
||||
@@ -1172,7 +1173,7 @@ namespace PhysicsTools
|
||||
{
|
||||
if (lstSegments.Count < num + 1 + 1)
|
||||
{
|
||||
// UnityEngine.Debug.LogError("!!! changeLength lstSegments size error index !!!: " + num);
|
||||
UnityEngine.Debug.LogError("!!! changeLength lstSegments size error index !!!: " + num);
|
||||
// if (GameController.Instance.fishingPlayer.currentState == FishingPlayer.PlayerState.FISHING ||
|
||||
// GameController.Instance.fishingPlayer.currentState == FishingPlayer.PlayerState.ICE_FISHING)
|
||||
// {
|
||||
@@ -1450,22 +1451,22 @@ namespace PhysicsTools
|
||||
getSegmentProperties(), this);
|
||||
segment.seg.transform.parent = base.gameObject.transform;
|
||||
// if ((bool)GameController.Instance)
|
||||
// {
|
||||
// segment.meshRenderer.enabled = true;
|
||||
// segment.meshRenderer.material = GameController.Instance.waterInteractiveMaterial;
|
||||
// segment.meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
|
||||
// }
|
||||
// else
|
||||
{
|
||||
segment.meshRenderer.enabled = false;
|
||||
segment.meshRenderer.enabled = true;
|
||||
// segment.meshRenderer.material = GameController.Instance.waterInteractiveMaterial;
|
||||
segment.meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
|
||||
}
|
||||
|
||||
// if (totalLength <= 105f)
|
||||
// else
|
||||
// {
|
||||
// segment.waterInteractive = segment.seg.AddComponent<WaterInteractive>();
|
||||
// segment.waterInteractive.Multiplier = 1.5f;
|
||||
// segment.meshRenderer.enabled = false;
|
||||
// }
|
||||
|
||||
if (totalLength <= 105f)
|
||||
{
|
||||
// segment.waterInteractive = segment.seg.AddComponent<WaterInteractive>();
|
||||
// segment.waterInteractive.Multiplier = 1.5f;
|
||||
}
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
|
||||
3
Assets/Scripts/ThirdParty/PhysicsTools/Test.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/PhysicsTools/Test.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2aeb581d8e0340a7b32560ea8d661608
|
||||
timeCreated: 1762030053
|
||||
145
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTest.cs
vendored
Normal file
145
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTest.cs
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace PhysicsTools
|
||||
{
|
||||
public class RopeTest : MonoBehaviour
|
||||
{
|
||||
public Rope rope;
|
||||
|
||||
public Transform startPosition;
|
||||
|
||||
public Transform throwPosition;
|
||||
|
||||
public Transform ropeStart;
|
||||
|
||||
public Transform ropeFloat;
|
||||
|
||||
public Transform ropeBait;
|
||||
|
||||
public Transform fishingPlayer;
|
||||
|
||||
public bool updateDistance;
|
||||
|
||||
public float incDist = 0.1f;
|
||||
|
||||
public float incDistThrow = 0.5f;
|
||||
|
||||
public float incDistWater = 0.1f;
|
||||
|
||||
public float maxLength = 25f;
|
||||
|
||||
public Vector3 throwDir = Vector3.zero;
|
||||
|
||||
public float throwForce = 1000f;
|
||||
|
||||
public float prevDistance = -1f;
|
||||
|
||||
public float currentDistance = -1f;
|
||||
|
||||
public float reelInSpeed = 0.01f;
|
||||
|
||||
[HideInInspector] public float reelInFactor;
|
||||
|
||||
private bool hitWater;
|
||||
|
||||
private bool wasThrown;
|
||||
|
||||
public bool hasFish;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
prevDistance = (currentDistance = CalculateDistance());
|
||||
ResetBait(true);
|
||||
ropeStart.parent = null;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (hitWater && rope.getLength() < 1f)
|
||||
{
|
||||
ResetBait();
|
||||
return;
|
||||
}
|
||||
|
||||
reelInFactor = 0f;
|
||||
if (Input.GetKey(KeyCode.N))
|
||||
{
|
||||
reelInFactor = reelInSpeed;
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.M))
|
||||
{
|
||||
reelInFactor = 0f - reelInSpeed;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.B))
|
||||
{
|
||||
ThrowBait();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.V))
|
||||
{
|
||||
ResetBait(true);
|
||||
}
|
||||
|
||||
ReelIn(reelInFactor);
|
||||
if (!hitWater && ropeStart.position.y <= 0f)
|
||||
{
|
||||
incDist = incDistWater;
|
||||
hitWater = true;
|
||||
}
|
||||
|
||||
ropeStart.GetComponent<Rigidbody>().linearDamping = ((!(ropeStart.position.y <= 0f)) ? 0f : 5f);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
prevDistance = currentDistance;
|
||||
currentDistance = CalculateDistance();
|
||||
if (updateDistance && (!hitWater || hasFish) && rope.getLength() < maxLength && wasThrown &&
|
||||
rope.getLength() < currentDistance + incDist)
|
||||
{
|
||||
rope.changeLength(currentDistance - rope.getLength() + incDist);
|
||||
}
|
||||
|
||||
Debug.Log("currentDistance: " + currentDistance + " rope.getLength(): " + rope.getLength());
|
||||
}
|
||||
|
||||
public void ReelIn(float reelIn)
|
||||
{
|
||||
if (reelIn < 0f && rope.getLength() <= rope.segPropertiesCylinder.length)
|
||||
{
|
||||
reelIn = 0f;
|
||||
}
|
||||
|
||||
rope.rate = reelIn;
|
||||
}
|
||||
|
||||
public float CalculateDistance()
|
||||
{
|
||||
return Vector3.Distance(ropeStart.position, ropeFloat.position);
|
||||
}
|
||||
|
||||
public void ThrowBait()
|
||||
{
|
||||
incDist = incDistThrow;
|
||||
ropeStart.position = throwPosition.position;
|
||||
rope.regenerateRope(true);
|
||||
ropeStart.GetComponent<Rigidbody>().AddForce((fishingPlayer.forward + throwDir).normalized * throwForce);
|
||||
Debug.DrawLine(ropeStart.position,
|
||||
ropeStart.position + (fishingPlayer.forward + throwDir).normalized * throwForce, Color.yellow, 5f);
|
||||
wasThrown = true;
|
||||
}
|
||||
|
||||
public void ResetBait(bool quick = false)
|
||||
{
|
||||
if (quick)
|
||||
{
|
||||
ropeStart.position = startPosition.position;
|
||||
rope.regenerateRope(true);
|
||||
}
|
||||
|
||||
hitWater = false;
|
||||
wasThrown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTest.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTest.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8120306974a64ee3b78322d877915631
|
||||
timeCreated: 1762029973
|
||||
85
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTestLogic.cs
vendored
Normal file
85
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTestLogic.cs
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace PhysicsTools
|
||||
// {
|
||||
// public class RopeTestLogic : MonoBehaviour
|
||||
// {
|
||||
// public GameObject fishingRod;
|
||||
//
|
||||
// public GameObject bait;
|
||||
//
|
||||
// public GameObject baitStartPos;
|
||||
//
|
||||
// public GameObject rodEndPos;
|
||||
//
|
||||
// public UltimateRope rope;
|
||||
//
|
||||
// public float throwStrength = 10f;
|
||||
//
|
||||
// public float ropeLengthMargin = 3f;
|
||||
//
|
||||
// private bool isThrown;
|
||||
//
|
||||
// private void Start()
|
||||
// {
|
||||
// rope.Regenerate();
|
||||
// rope.GetComponent<RopeAdditionalParams>().UpdateNodes(rope);
|
||||
// }
|
||||
//
|
||||
// private void Update()
|
||||
// {
|
||||
// if (Input.GetKeyDown(KeyCode.T))
|
||||
// {
|
||||
// ThrowBait();
|
||||
// }
|
||||
//
|
||||
// if (Input.GetKeyDown(KeyCode.R))
|
||||
// {
|
||||
// ResetBait();
|
||||
// }
|
||||
//
|
||||
// if (Input.GetKeyDown(KeyCode.Z))
|
||||
// {
|
||||
// rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, -0.1f);
|
||||
// }
|
||||
// else if (Input.GetKeyDown(KeyCode.X))
|
||||
// {
|
||||
// rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, 0.1f);
|
||||
// }
|
||||
//
|
||||
// if (isThrown)
|
||||
// {
|
||||
// UpdateRope();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void UpdateRope()
|
||||
// {
|
||||
// float num = Vector3.Distance(rodEndPos.transform.position, bait.transform.position);
|
||||
// if (rope.m_fCurrentExtension < num + ropeLengthMargin - rope.RopeNodes[0].fLength)
|
||||
// {
|
||||
// rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement,
|
||||
// num + ropeLengthMargin - rope.RopeNodes[0].fLength - rope.m_fCurrentExtension);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void ThrowBait()
|
||||
// {
|
||||
// bait.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
// Vector3 forward = base.transform.forward;
|
||||
// bait.GetComponent<Rigidbody>().isKinematic = false;
|
||||
// bait.GetComponent<Rigidbody>().AddForce(forward * throwStrength);
|
||||
// isThrown = true;
|
||||
// }
|
||||
//
|
||||
// public void ResetBait()
|
||||
// {
|
||||
// bait.transform.position = baitStartPos.transform.position;
|
||||
// bait.GetComponent<Rigidbody>().isKinematic = true;
|
||||
// bait.GetComponent<Rigidbody>().velocity = Vector3.zero;
|
||||
// bait.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
|
||||
// rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, 0f - rope.m_fCurrentExtension);
|
||||
// isThrown = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
3
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTestLogic.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/PhysicsTools/Test/RopeTestLogic.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15b3231410b74742829eccac62da7670
|
||||
timeCreated: 1762030063
|
||||
@@ -32,7 +32,7 @@ namespace NBF
|
||||
Content.Gear.SetInfo(ItemInfo);
|
||||
|
||||
// var model = PrefabsHelper.CreatePrefab(ItemInfo.Config.Model);
|
||||
Model.SetData(ItemInfo.Config);
|
||||
Model.SetData(ItemInfo);
|
||||
// Model.SetBackground(Back);
|
||||
|
||||
Game.Input.OnUICanceled += OnUICanceled;
|
||||
|
||||
@@ -74,21 +74,18 @@ namespace NBF
|
||||
_camera.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void LoadModel(string model, ModelViewerSettings settings)
|
||||
public void SetModel(GameObject model, ModelViewerSettings settings)
|
||||
{
|
||||
this.UnloadModel();
|
||||
ViewerSettings = settings;
|
||||
|
||||
Object prefab = Resources.Load(model);
|
||||
if (prefab == null) return;
|
||||
GameObject go = ((GameObject)Object.Instantiate(prefab));
|
||||
var joint = go.GetComponent<Joint>();
|
||||
if (model == null) return;
|
||||
var joint = model.GetComponent<Joint>();
|
||||
if (joint != null)
|
||||
{
|
||||
Object.Destroy(joint);
|
||||
}
|
||||
|
||||
_model = go.transform;
|
||||
_model = model.transform;
|
||||
_model.SetParent(this.modelRoot, false);
|
||||
_model.localPosition = Vector3.zero;
|
||||
_model.localScale = Vector3.one;
|
||||
@@ -96,12 +93,40 @@ namespace NBF
|
||||
if (ViewerSettings == null)
|
||||
{
|
||||
ViewerSettings = new ModelViewerSettings();
|
||||
ModelViewerUtils.InitSetting(go, ViewerSettings);
|
||||
ModelViewerUtils.InitSetting(model, ViewerSettings);
|
||||
}
|
||||
|
||||
Review();
|
||||
}
|
||||
|
||||
// public void LoadModel(string model, ModelViewerSettings settings)
|
||||
// {
|
||||
// this.UnloadModel();
|
||||
// ViewerSettings = settings;
|
||||
//
|
||||
// Object prefab = Resources.Load(model);
|
||||
// if (prefab == null) return;
|
||||
// GameObject go = ((GameObject)Object.Instantiate(prefab));
|
||||
// var joint = go.GetComponent<Joint>();
|
||||
// if (joint != null)
|
||||
// {
|
||||
// Object.Destroy(joint);
|
||||
// }
|
||||
//
|
||||
// _model = go.transform;
|
||||
// _model.SetParent(this.modelRoot, false);
|
||||
// _model.localPosition = Vector3.zero;
|
||||
// _model.localScale = Vector3.one;
|
||||
// _model.localEulerAngles = Vector3.zero;
|
||||
// if (ViewerSettings == null)
|
||||
// {
|
||||
// ViewerSettings = new ModelViewerSettings();
|
||||
// ModelViewerUtils.InitSetting(go, ViewerSettings);
|
||||
// }
|
||||
//
|
||||
// Review();
|
||||
// }
|
||||
|
||||
public void UnloadModel()
|
||||
{
|
||||
if (_model != null)
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace NBF
|
||||
|
||||
public ModelViewerSettings ViewerSettings => _renderImage.ViewerSettings;
|
||||
|
||||
private ItemConfig _itemConfig;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
_renderImage = new ModelViewRenderImage(ModelHolder.asGraph);
|
||||
@@ -37,21 +35,12 @@ namespace NBF
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
public void SetData(uint itemId)
|
||||
|
||||
public void SetData(ItemInfo itemInfo)
|
||||
{
|
||||
SetData(ItemConfig.Get(itemId));
|
||||
_renderImage.SetModel(PrefabsHelper.CreateItem(itemInfo), ModelViewerSettings.Load(itemInfo.ConfigId));
|
||||
}
|
||||
|
||||
public void SetData(ItemConfig itemConfig)
|
||||
{
|
||||
_itemConfig = itemConfig;
|
||||
_renderImage.LoadModel(itemConfig.GetModelPath(), ModelViewerSettings.Load(itemConfig.Id));
|
||||
}
|
||||
|
||||
public void ReSetSetting(ItemConfig itemConfig)
|
||||
{
|
||||
_renderImage.LoadModel(itemConfig.GetModelPath(), null);
|
||||
}
|
||||
|
||||
public void UnloadModel()
|
||||
{
|
||||
@@ -126,9 +115,7 @@ namespace NBF
|
||||
|
||||
#endregion
|
||||
|
||||
#region 保存png
|
||||
|
||||
public void SaveRenderTextureToPNG()
|
||||
public void SaveRenderTextureToPNG(uint id)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
RenderTexture rt = RenderImage.RT;
|
||||
@@ -165,16 +152,14 @@ namespace NBF
|
||||
resizedTex.Apply();
|
||||
|
||||
byte[] bytes = resizedTex.EncodeToPNG();
|
||||
var path = Path.Combine(Application.dataPath, $"Resources/Icons/{_itemConfig.Id}.png");
|
||||
var path = Path.Combine(Application.dataPath, $"Resources/Icons/{id}.png");
|
||||
File.WriteAllBytes(path, bytes);
|
||||
Debug.Log($"✅ RenderTexture 已保存到: {path}");
|
||||
Notices.Info($"生成:{_itemConfig.Id}");
|
||||
Notices.Info($"生成:{id}");
|
||||
|
||||
Object.Destroy(tex);
|
||||
RenderTexture.active = current;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,15 @@ namespace NBF
|
||||
Game.Input.OnUICanceled += OnUICanceled;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
// base.OnUpdate();
|
||||
if (Input.GetKeyDown(KeyCode.F9))
|
||||
{
|
||||
PreviewPanel.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (action == InputDef.UI.Back)
|
||||
|
||||
@@ -29,7 +29,12 @@ namespace NBF
|
||||
Basic.SetInfo(ItemInfo);
|
||||
|
||||
// var model = PrefabsHelper.CreatePrefab(ItemInfo.Config.Model);
|
||||
Model.SetData(ItemInfo.Config);
|
||||
Model.SetData(new ItemInfo()
|
||||
{
|
||||
Id = ItemInfo.Config.Id,
|
||||
ConfigId = ItemInfo.Config.Id,
|
||||
Count = 1,
|
||||
});
|
||||
// Model.SetBackground(Back);
|
||||
|
||||
Game.Input.OnUICanceled += OnUICanceled;
|
||||
@@ -57,7 +62,7 @@ namespace NBF
|
||||
{
|
||||
if (btn == BtnSaveIcon)
|
||||
{
|
||||
Model.SaveRenderTextureToPNG();
|
||||
Model.SaveRenderTextureToPNG(ItemInfo.Config.Id);
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
@@ -75,8 +80,10 @@ namespace NBF
|
||||
}
|
||||
else if (btn == BtnReSet)
|
||||
{
|
||||
Model.ReSetSetting(ItemInfo.Config);
|
||||
// Model.ReSetSetting(ItemInfo.Config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -132,9 +132,15 @@ namespace NBF
|
||||
foreach (var item in _itemInfos)
|
||||
{
|
||||
GenModel.visible = true;
|
||||
GenModel.SetData(item.Config);
|
||||
// GenModel.SetData(item.Config);
|
||||
GenModel.SetData(new ItemInfo()
|
||||
{
|
||||
Id = item.Config.Id,
|
||||
ConfigId = item.Config.Id,
|
||||
Count = 1,
|
||||
});
|
||||
yield return new WaitForSeconds(1f);
|
||||
GenModel.SaveRenderTextureToPNG();
|
||||
GenModel.SaveRenderTextureToPNG(item.Config.Id);
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user