Что я сдал
This commit is contained in:
1 parent
24b1157026
commit
a5665f0101
2838 files changed
+129953
-1304
No files matched your search
@@ -7,6 +7,39 @@ using Random = UnityEngine.Random;
|
||||
|
||||
namespace Code.GameplayServices
|
||||
{
|
||||
// [OnListViewChanged(
|
||||
// OnItemChanged = nameof(OnPassingObjectsPresetsChanged),
|
||||
// OnItemsAdded = nameof(OnPassingObjectsPresetsAdded),
|
||||
// OnItemsRemoved = nameof(OnPassingObjectsPresetsRemoved),
|
||||
// OnSelectedIndicesChanged = nameof(OnPassingObjectsPresetsIndicesChanged),
|
||||
// OnItemIndexChanged = nameof(OnPassingObjectsPresetsIndexChanged))
|
||||
// ]
|
||||
// public float[] array;
|
||||
//
|
||||
// void OnPassingObjectsPresetsChanged(int index, PassingObjectsPreset item)
|
||||
// {
|
||||
// Debug.Log($"Changed: [{index}] -> {item}");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsAdded(IEnumerable<int> indices)
|
||||
// {
|
||||
// Debug.Log($"Added: [{string.Join(',', indices)}]");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsRemoved(IEnumerable<int> indices)
|
||||
// {
|
||||
// Debug.Log($"Removed: [{string.Join(',', indices)}]");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsIndicesChanged(IEnumerable<int> indices)
|
||||
// {
|
||||
// Debug.Log($"Selected: [{string.Join(',', indices)}]");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsIndexChanged(int before, int after)
|
||||
// {
|
||||
// Debug.Log($"Index Changed: [{before} -> {after}]");
|
||||
// }
|
||||
public class PassingObjectsManager : MonoBehaviour
|
||||
{
|
||||
[TabGroup("Spawn")] [SerializeField] private List<Transform> spawnPoints;
|
||||
@@ -18,9 +51,43 @@ namespace Code.GameplayServices
|
||||
[TabGroup("Gameplay")] [SerializeField]
|
||||
private float obstacleCooldown;
|
||||
|
||||
[OnListViewChanged(
|
||||
OnItemChanged = nameof(OnPassingObjectsPresetsChanged),
|
||||
OnItemsAdded = nameof(OnPassingObjectsPresetsAdded),
|
||||
OnItemsRemoved = nameof(OnPassingObjectsPresetsRemoved),
|
||||
OnSelectedIndicesChanged = nameof(OnPassingObjectsPresetsIndicesChanged),
|
||||
OnItemIndexChanged = nameof(OnPassingObjectsPresetsIndexChanged))
|
||||
]
|
||||
[TabGroup("Gameplay")] [SerializeField]
|
||||
private List<PassingObjectsPreset> obstaclesPresets;
|
||||
|
||||
|
||||
void OnPassingObjectsPresetsChanged(int index, PassingObjectsPreset item)
|
||||
{
|
||||
float totalChance = 0f;
|
||||
for (var i = 0; i < obstaclesPresets.Count; i++)
|
||||
{
|
||||
if (i == index) continue;
|
||||
totalChance += obstaclesPresets[i].chance;
|
||||
}
|
||||
|
||||
if(item.chance > 1 - totalChance) item.chance = 1 - totalChance;
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsAdded(IEnumerable<int> indices)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsRemoved(IEnumerable<int> indices)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsIndicesChanged(IEnumerable<int> indices)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsIndexChanged(int before, int after)
|
||||
{
|
||||
}
|
||||
private List<GameObject> _spawnedObjects = new();
|
||||
public float BehindPlayerThreshold => behindPlayerThreshold;
|
||||
public static PassingObjectsManager Instance { get; private set; }
|
||||
@@ -62,6 +129,7 @@ namespace Code.GameplayServices
|
||||
if (prefabs.Count == 0 && obstaclesPresets.Count > 0) return;
|
||||
|
||||
var presetId = Random.Range(0, obstaclesPresets.Count);
|
||||
var chance = Random.Range(0,1f);
|
||||
|
||||
_spawnedObjects.Add(
|
||||
Instantiate(
|
||||
@@ -87,5 +155,7 @@ namespace Code.GameplayServices
|
||||
public int prefabId1;
|
||||
public int prefabId2;
|
||||
public int prefabId3;
|
||||
[Range(0,1f)]
|
||||
public float chance;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user