Files
2026-03-04 10:03:45 +08:00

164 lines
3.4 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace UFS2.ScriptableObjects
{
[CreateAssetMenu(fileName = "FishData", menuName = "Data/FishData")]
public class FishData : ScriptableObject
{
public int ID;
public string Name;
public GameManager.FishSpecies Species;
public FishMoveSpeed MoveSpeedType;
public FishBehaviourType BehaviourType;
public float Weight = 0.2f;
public float WeightMax;
public FishDeepType FishDeepType;
public float MoveSpeed;
public float MoveMaxSpeed;
public float MoveSpeedDashMultiplier;
public float RotateSpeed = 15f;
public GameObject[] PrefabModels;
public float Strenght = 1f;
public float StaminaMax = 1f;
public float CashReward;
public int RankingPointReward;
[Header("Fighting setting")]
public int JumpRatio;
public int DiveRatio;
public int SwimToSurfaceRatio;
public int SwimIntoHideoutRatio;
public int SwimInDifferentDirectionsRatio;
public int StickToBottomRatio;
public int EnergyBurstRatio;
[SerializeField]
[Tooltip("How many stamina drop per seconds")]
private float staminaDropRate;
private float attackAgresive = 2.5f;
public Vector2[] weightLenghtValues;
public AnimationCurve weightLengthCurve;
public string[] modelPath;
public string[] imagePath;
public string[] modelTrophyPath;
public List<GameManager.AcceptFishBait> acceptFishBaits;
public List<GameManager.AcceptFishBait> acceptFishLures;
public Sprite GetIconImage(int index)
{
return Resources.Load<Sprite>("Icons/Fish/" + imagePath[index]);
}
public float ConvertWeightFishToLength(float weight)
{
return weightLengthCurve.Evaluate(weight);
}
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)
{
float num = weightLengthCurve.Evaluate(weight) * 0.0185f;
return Vector3.one * num;
}
public GameObject GetTrophyModelPrefab(float weight)
{
if (weight > WeightMax)
{
weight = WeightMax;
}
float num = WeightMax / (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 LoadFishResource(out float weight)
{
return GetFishModel(weight = Random.Range(0f, WeightMax));
}
private GameObject GetFishModel(float weight)
{
if (weight > WeightMax)
{
weight = WeightMax;
}
float num = WeightMax / (float)modelPath.Length;
int num2 = (int)(weight / num);
if (num2 >= modelPath.Length)
{
num2 = modelPath.Length - 1;
}
return Resources.Load("GameItemsPrefabs/Fish/" + modelPath[num2]) as GameObject;
}
public GameObject LoadFishResource(float weight)
{
return GetFishModel(weight);
}
public Sprite GetFishIcon(float weight)
{
if (weight > WeightMax)
{
weight = WeightMax;
}
float num = WeightMax / (float)modelPath.Length;
int num2 = (int)(weight / num);
if (num2 >= modelPath.Length)
{
num2 = modelPath.Length - 1;
}
return GetIconImage(num2);
}
public string GetFishName()
{
return GameManager.GetFishNameFromSpecies(Species);
}
}
}