Files
butchers-games-test/Assets/Scripts/Game/Core/CoreDef.cs
T
Boris Nikolaev 5f1e94b653 add project files
2026-08-14 01:58:31 +03:00

93 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
using OHM.UnityToolkit;
[CreateAssetMenu(fileName = "CoreGameDef", menuName = "GameSqueleton/New Core Game Def")]
public class CoreDef : ScriptableObject
{
[Serializable]
public class TextByRich : SerializableDictionary<int, TypeRich>
{
}
public PlayerDef player;
public float levelWidth;
public AI ai;
[Header("Revive")]
public float maxReviveDuration;
public float reviveProtectionDuration;
[Header("Timing")]
public float sectionEndingDuration = 0.5f;
public float sectionTransitionDuration = 1f;
[Header("Currencies")]
public CoreCurrenciesDef currencies;
public GameObject keyPrefab;
[Header("Levels/ Progression")]
[SerializeField]
private ProgressionDef progression;
[Header("Debug")]
public bool showHumanHand;
public TextByRich textByRich;
public ProgressionDef GetProgression()
{
return progression;
}
public LevelDef GetLevel(long index)
{
List<LevelDef> list = GetProgression().levelsDiffPath;
LevelDef result = null;
int acc = 0;
int cur = -1;
foreach (LevelDef level in list)
{
if (acc > index)
{
break;
}
cur += level.levelCount;
acc = cur + 1;
result = level;
}
return result ?? list[0];
}
public TypeRich GetTextRich(int rich)
{
TypeRich result = textByRich[0];
int best = 0;
foreach (KeyValuePair<int, TypeRich> kv in textByRich)
{
if (kv.Key <= rich && best <= kv.Key)
{
best = kv.Key;
result = kv.Value;
}
}
return result;
}
public bool HaveMinLevelRich(string level, int rich)
{
foreach (KeyValuePair<int, TypeRich> kv in textByRich)
{
if (kv.Value.text == level)
{
return kv.Key <= rich;
}
}
return false;
}
}