Files
Fishing2/Assets/Scripts/Configs/Mem/GameFish.cs
2025-05-10 12:49:47 +08:00

134 lines
3.4 KiB
C#

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 GameFish : ConfigBase
{
public static GameFish 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]);
}
}
}