52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UFS2.ScriptableObjects;
|
|
using UnityEngine;
|
|
|
|
namespace ShiningGames.UFS2
|
|
{
|
|
[Serializable]
|
|
public class FishTargetArea
|
|
{
|
|
public List<FishTarget> OverallPoints;
|
|
|
|
public List<FishTarget> BottomPoints;
|
|
|
|
public List<FishTarget> SurfacePoints;
|
|
|
|
public Collider[] Volumes;
|
|
|
|
public FishTarget GetRandomTarget(FishBehaviourType fishBehaviourType)
|
|
{
|
|
FishTarget fishTarget = null;
|
|
fishTarget = fishBehaviourType switch
|
|
{
|
|
FishBehaviourType.PassivePredator => (UnityEngine.Random.value > 0.5f) ? GetRandomPoint(OverallPoints) : GetRandomPoint(BottomPoints),
|
|
FishBehaviourType.Deep => GetRandomPoint(BottomPoints),
|
|
_ => GetRandomPoint(OverallPoints),
|
|
};
|
|
if (fishTarget == null)
|
|
{
|
|
fishTarget = GetRandomPoint(OverallPoints);
|
|
}
|
|
if (fishTarget == null)
|
|
{
|
|
fishTarget = GetRandomPoint(BottomPoints);
|
|
}
|
|
if (fishTarget == null)
|
|
{
|
|
fishTarget = GetRandomPoint(SurfacePoints);
|
|
}
|
|
return fishTarget;
|
|
static FishTarget GetRandomPoint(List<FishTarget> points)
|
|
{
|
|
if (points == null || points.Count <= 0)
|
|
{
|
|
return null;
|
|
}
|
|
return points[UnityEngine.Random.Range(0, points.Count)];
|
|
}
|
|
}
|
|
}
|
|
}
|