add project files

This commit is contained in:
Boris Nikolaev
2026-08-14 01:58:31 +03:00
parent 9134cad79b
commit 5f1e94b653
4399 changed files with 12286903 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4fe99f8eaeea7f24b9bf2c5015450671
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,240 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using OHM.UnityToolkit;
using UnityEngine.Serialization;
namespace Ambiance
{
public class AmbianceController : UniqueInstance<AmbianceController>
{
[SerializeField]
public AmbiancesDef ambiancesDef;
[SerializeField]
[FormerlySerializedAs("skyMatRef")]
private Material _skyMatRef;
[SerializeField]
[FormerlySerializedAs("dirLight")]
private Light _dirLight;
private Camera camera;
public Dictionary<string, Color> debugColors = new Dictionary<string, Color>();
public int changeAmbianceSectionCount = 1;
private AmbianceDef _forcedAmbiance;
private bool currentlyOnFire;
public UnityEvent OnAmbianceChange;
public AmbianceDef CurrentAmbiance { get; private set; }
public AmbianceDef CurrentAmbianceToUse { get; private set; }
public int CurrentLevelIdx { get; private set; }
public int CurrentAmbianceIdx { get; private set; }
public int CurrentAmbianceRealIdx { get; private set; }
public Material SkyMat { get; private set; }
public Dictionary<string, Material> SpecialMats { get; private set; }
public bool Flip { get; set; }
public string _debugSkyColorKey { get; private set; } = "debug_sky_color";
public string GetFlippedId(string id)
{
return id + "_f";
}
protected override void AwakeInstance()
{
SpecialMats = new Dictionary<string, Material>();
foreach (SpecialMatDef def in ambiancesDef.specialsMatRef)
{
var mat = new Material(def.materialRef);
mat.name = mat.name + "_" + def.id;
SpecialMats[def.id] = mat;
if (!def.flippable)
{
continue;
}
var flipped = new Material(def.materialRef);
string flippedId = GetFlippedId(def.id);
flipped.name = flipped.name + "_" + flippedId;
flipped.mainTextureScale = new Vector2(flipped.mainTextureScale.x, 0f - flipped.mainTextureScale.y);
SpecialMats[flippedId] = flipped;
}
if (_skyMatRef != null)
{
SkyMat = new Material(_skyMatRef);
RenderSettings.skybox = SkyMat;
}
}
public void UpdateCameraAmbiance(Camera camera)
{
this.camera = camera;
SetAmbiance(CurrentAmbiance, currentlyOnFire);
}
public void ForceAmbiance(AmbianceDef amb)
{
_forcedAmbiance = amb;
SetLevelIdx(CurrentLevelIdx, currentlyOnFire, forceReload: true);
}
public void SetLevelIdx(int levelIdx, bool onFire, bool forceReload)
{
if (!forceReload && CurrentLevelIdx == levelIdx && currentlyOnFire == onFire)
{
return;
}
CurrentLevelIdx = levelIdx;
currentlyOnFire = onFire;
if (_forcedAmbiance != null)
{
SetAmbiance(_forcedAmbiance, onFire);
return;
}
CurrentAmbianceIdx = levelIdx / changeAmbianceSectionCount;
List<AmbianceDef> ambiances = ambiancesDef.GetAmbiancesList();
CurrentAmbianceRealIdx = CurrentAmbianceIdx % ambiances.Count;
SetAmbiance(ambiances[CurrentAmbianceRealIdx], onFire);
}
public void TryAmbiance(AmbianceDef ambianceDef, bool onFire)
{
SetAmbiance(ambianceDef, onFire);
}
public Material GetSpecialMat(string id, bool allowFlip = false)
{
if (SpecialMats == null)
{
return null;
}
if (Flip && allowFlip)
{
string flippedId = GetFlippedId(id);
if (SpecialMats.ContainsKey(flippedId))
{
return SpecialMats[flippedId];
}
}
if (SpecialMats.ContainsKey(id))
{
return SpecialMats[id];
}
return null;
}
private void SetAmbiance(AmbianceDef def, bool fire)
{
CurrentAmbiance = def;
AmbianceDef toUse = (fire && def != null && def.fireAmbiance != null) ? def.fireAmbiance : def;
CurrentAmbianceToUse = toUse;
if (toUse == null)
{
return;
}
RenderSettings.fogColor = toUse.fogColor;
ApplySpecialColor(toUse);
if (SkyMat != null)
{
if (debugColors.ContainsKey(_debugSkyColorKey))
{
Color debugColor = debugColors[_debugSkyColorKey];
SkyMat.SetColor("_SkyColor1", debugColor);
SkyMat.SetColor("_SkyColor2", debugColor);
SkyMat.SetColor("_SkyColor3", debugColor);
}
else
{
SkyMat.SetTexture("_MainTex", def.skyPano);
}
}
FogDistance fog = (def.fogDistance != null) ? def.fogDistance : ambiancesDef.defaultFogDistance;
RenderSettings.fogStartDistance = fog.start;
RenderSettings.fogEndDistance = fog.end;
OnAmbianceChange.Invoke();
}
private void ApplySpecialColor(AmbianceDef def)
{
if (def == null || def.specialColors == null)
{
return;
}
foreach (SpecialColorDef sc in def.specialColors)
{
Material mat = GetSpecialMat(sc.id);
if (mat != null)
{
ApplySpecialColorToMat(mat, sc);
}
else
{
Debug.LogErrorFormat(
"Ambiance {0} is trying to set undefined special material {1}. Please check ambiance or def",
def.name, sc.id);
}
Material flipped = GetSpecialMat(GetFlippedId(sc.id));
if (flipped != null)
{
ApplySpecialColorToMat(flipped, sc);
}
}
}
private void ApplySpecialColorToMat(Material specMat, SpecialColorDef sc)
{
if (debugColors.ContainsKey(sc.id))
{
Color debugColor = debugColors[sc.id];
specMat.SetColor("_TintColor", debugColor);
specMat.SetColor("_ColorAdd", debugColor);
specMat.SetColor("_EmissionColor", debugColor);
specMat.mainTexture = null;
return;
}
specMat.color = sc.color;
if (specMat.HasProperty("_TintColor"))
{
specMat.SetColor("_TintColor", sc.color);
}
if (specMat.HasProperty("_ColorAdd"))
{
specMat.SetColor("_ColorAdd", sc.colorAdd);
}
if (specMat.HasProperty("_EmissionColor"))
{
specMat.EnableKeyword("_EMISSION");
specMat.SetColor("_EmissionColor", sc.colorEmission);
}
if (specMat.HasProperty("_EmissionMap") && sc.textureEmission != null)
{
specMat.SetTexture("_EmissionMap", sc.textureEmission);
}
if (sc.texture != null)
{
specMat.mainTexture = sc.texture;
return;
}
SpecialMatDef matDef = ambiancesDef.specialsMatRef.Find((SpecialMatDef d) => d.id == sc.id);
if (matDef != null)
{
specMat.mainTexture = matDef.materialRef.mainTexture;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7c4cac1f1af73cb2609e0a302aa19a09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 200
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using System.Collections.Generic;
using UnityEngine;
namespace Ambiance
{
[CreateAssetMenu(fileName = "AmbianceDef", menuName = "GameSqueleton/New Ambiance Def")]
public class AmbianceDef : ScriptableObject
{
public Sprite thumb;
public FogDistance fogDistance;
[Header("Skybox")]
public Texture skyPano;
public Color fogColor;
[Header("Special Color")]
public List<SpecialColorDef> specialColors;
[Header("Special Prefabs")]
public List<SpecialPrefabDef> specialPrefabs;
[Header("Show elements")]
public List<string> showElementsIds;
[Header("Hide elements")]
public List<string> hiddenElementsIds;
[Header("FIRE")]
public AmbianceDef fireAmbiance;
[ContextMenu("Try default")]
private void Try()
{
AmbianceController.Instance.TryAmbiance(this, onFire: false);
}
[ContextMenu("Try on fire")]
private void TryFire()
{
AmbianceController.Instance.TryAmbiance(this, onFire: true);
}
public SpecialColorDef GetSpecialColor(string id)
{
return specialColors.Find((SpecialColorDef c) => c.id == id);
}
public SpecialPrefabDef GetSpecialPrefab(string id)
{
return specialPrefabs.Find((SpecialPrefabDef p) => p.id == id);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: daffb0eeda04a1cb814b5a7ac7d4b688
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
using UnityEngine;
namespace Ambiance
{
public class AmbianceHide : AmbianceSpecialBase
{
[SerializeField]
private string id;
public override void OnStart()
{
base.OnStart();
AmbianceController.Instance.OnAmbianceChange.AddListener(Apply);
}
public override void Apply()
{
Renderer renderer = GetComponent<Renderer>();
if (renderer == null || AmbianceController.Instance.CurrentAmbianceToUse == null)
{
return;
}
renderer.enabled = !AmbianceController.Instance.CurrentAmbianceToUse.hiddenElementsIds.Contains(id);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e490207be0cec601ce6768721850d6eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using OHM.UnityToolkit.Pooling;
using UnityEngine.Serialization;
namespace Ambiance
{
public class AmbianceShow : AmbianceSpecialBase
{
[Serializable]
public class OptionalObject
{
public Transform position;
public PooledObject objectToInstantiate;
}
[SerializeField]
private string id;
[SerializeField]
[FormerlySerializedAs("randomShow")]
private bool _randomShow;
[SerializeField]
[Tooltip("position, prefab")]
[FormerlySerializedAs("objectsList")]
private List<OptionalObject> _objectsList;
public override void OnStart()
{
base.OnStart();
AmbianceController.Instance.OnAmbianceChange.AddListener(Apply);
}
public override void Apply()
{
if (GetComponent<Renderer>() == null && AmbianceController.Instance == null)
{
return;
}
AmbianceDef ambiance = AmbianceController.Instance.CurrentAmbianceToUse;
if (ambiance == null)
{
return;
}
bool show = ambiance.showElementsIds.Contains(id);
DisableObject();
if (!show)
{
return;
}
int index = _randomShow ? UnityEngine.Random.Range(0, _objectsList.Count) : 0;
if (_objectsList.Count == 0)
{
return;
}
OptionalObject slot = _objectsList[index];
if (slot == null || slot.objectToInstantiate == null || slot.position == null)
{
return;
}
PoolsManager.InstantiatePrefab(slot.objectToInstantiate, slot.position,
slot.position.position, slot.position.rotation, startActive: true);
}
private void DisableObject()
{
for (int i = 0; i < base.transform.childCount; i++)
{
base.transform.GetChild(i).gameObject.SetActive(false);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 11d94c18dc7ae664bd2b7c65c19848fc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace Ambiance
{
public class AmbianceSpecialBase : MonoBehaviour
{
[SerializeField]
[FormerlySerializedAs("autoApply")]
private bool _autoApply = true;
private void Start()
{
OnStart();
}
public virtual void OnStart()
{
if (_autoApply)
{
Apply();
}
}
public virtual void Apply()
{
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 173e8ce0439a4cf1e757b77a050776ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,40 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace Ambiance
{
public class AmbianceSpecialColor : AmbianceSpecialBase
{
[SerializeField]
public string id;
[SerializeField]
[FormerlySerializedAs("matIdx")]
private int _matIdx;
[SerializeField]
private bool allowFlip;
public override void Apply()
{
Renderer renderer = GetComponent<Renderer>();
if (renderer == null)
{
return;
}
Material specialMat = AmbianceController.Instance.GetSpecialMat(id, allowFlip);
if (specialMat == null)
{
Debug.LogErrorFormat("AmbianceSpecialColor failed to find special material id {0}", id);
return;
}
Material[] materials = renderer.sharedMaterials;
if (_matIdx >= materials.Length)
{
return;
}
materials[_matIdx] = specialMat;
renderer.sharedMaterials = materials;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: add998f88bbbe1cc326e7b4db3730d7c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ambiance
{
[CreateAssetMenu(fileName = "AmbiancesDef", menuName = "GameSqueleton/New Ambiances Def")]
public class AmbiancesDef : ScriptableObject
{
[SerializeField]
public FogDistance defaultFogDistance;
[SerializeField]
[FormerlySerializedAs("ambiances")]
private List<AmbianceDef> _ambiances;
public List<SpecialMatDef> specialsMatRef;
public List<AmbianceDef> GetAmbiancesList()
{
return _ambiances;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 922a2bac4ec8e83ea7ae4d7712140826
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using UnityEngine;
namespace Ambiance
{
[CreateAssetMenu(fileName = "AmbiancesDef", menuName = "GameSqueleton/New Fog Distance")]
public class FogDistance : ScriptableObject
{
public float start = 240f;
public float end = 500f;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebea53ccbf2d9ef2d6c35d9b388c724d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
using System;
using UnityEngine;
namespace Ambiance
{
[Serializable]
public class SpecialColorDef
{
public string id;
public Color color;
public Color colorAdd;
public Texture texture;
[ColorUsage(true, true)]
public Color colorEmission;
public Texture textureEmission;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 835ee94a5c1f7fc458fa297e3ad0d697
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
using System;
using UnityEngine;
namespace Ambiance
{
[Serializable]
public class SpecialMatDef
{
public string id;
public Material materialRef;
public bool flippable;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 288eb634727de864f8b47efadb0a1dc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
using System;
using UnityEngine;
namespace Ambiance
{
[Serializable]
public class SpecialPrefabDef
{
public string id;
public Transform prefab;
public Vector3 offsetMin;
public Vector3 offsetMax;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df1ca367ac7e23141b42998fa285d2e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 04c4b454238be8947ac18b5ebfaaf5fd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+226
View File
@@ -0,0 +1,226 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using OHM.UnityToolkit;
using OHM.UnityToolkit.Inventory;
public class AppController : MonoBehaviour
{
public class TransformEvent : UnityEvent<Transform>
{
}
public const string EDITOR_NAME = "GameSqueleton";
public CoreController coreGame;
public SavedDataController savedDataController;
public MetaDef metaDef;
[HideInInspector]
public UnityEvent onGameExited;
[HideInInspector]
public UnityEvent onCurrenciesChanged;
[HideInInspector]
public UnityEvent onLevelChanged;
[HideInInspector]
public UnityEvent onLevelCleared;
[HideInInspector]
public UnityEvent onBestScoreChanged;
[NonSerialized]
public bool needRestart;
public System.Random random = new System.Random();
private CustomizableController<PlayerSkinDef, PlayerSkinData> _playerSkinController;
private CustomizableController<PickupsSkinDef, PickupsSkinData> _pickupsSkinsController;
public CustomizableController<PlayerSkinDef, PlayerSkinData> PlayerSkinController =>
_playerSkinController ?? (_playerSkinController = new PlayerSkinController(this));
public CustomizableController<PickupsSkinDef, PickupsSkinData> PickupsSkinsController =>
_pickupsSkinsController ?? (_pickupsSkinsController = new PickupsSkinsController(this));
public void Awake()
{
Application.targetFrameRate = 60;
Physics.autoSyncTransforms = false;
coreGame.onGameStarted.AddListener(OnGameStarted);
coreGame.onGameOver.AddListener(OnGameOver);
coreGame.onGameWon.AddListener(OnGameEnded);
coreGame.currenciesController.onWinCurrencies += OnWinCurrency;
}
public void Start()
{
AppSettings.Instance.Apply();
Quit();
}
internal void StartWaitForReadyThen(Action p)
{
StartCoroutine(WaitForReadyThen(p));
}
private IEnumerator WaitForReadyThen(Action action)
{
while (!coreGame.IsReadyToPlay())
{
yield return null;
}
action();
}
private void Update()
{
if (Application.isEditor && Input.GetKeyDown(KeyCode.R))
{
needRestart = true;
}
if (needRestart)
{
Restart();
needRestart = false;
}
if (Application.isEditor && Input.GetKeyDown(KeyCode.Q))
{
Quit();
}
if (Application.isEditor && Input.GetKeyDown(KeyCode.U))
{
DebugNextLevel();
}
}
public void Restart()
{
Quit();
coreGame.Go();
}
public void Quit()
{
onGameExited.Invoke();
PlayerSkinController.ApplyCurrent();
PickupsSkinsController.ApplyCurrent();
coreGame.Warmup(GetPlayerLevel());
}
public void Go()
{
coreGame.Go();
}
private void OnGameStarted()
{
}
private void OnGameEnded()
{
savedDataController.SavedData.inventory.AddReward(SavedDataTUType.LEVEL_IDX, 1L);
RegisterBestScore();
savedDataController.SaveData();
onLevelCleared.Invoke();
}
private void OnGameOver()
{
RegisterBestScore();
}
private void RegisterBestScore()
{
long score = coreGame.scoreController.Score;
if (score <= GetBestScore())
{
return;
}
savedDataController.SavedData.inventory.SetCount(SavedDataTUType.BEST_SCORE_DEFAULT, score);
savedDataController.SaveData();
onBestScoreChanged.Invoke();
}
public long GetBestScore()
{
return savedDataController.SavedData.inventory.GetCount(SavedDataTUType.BEST_SCORE_DEFAULT);
}
public long GetPlayerLevel()
{
return savedDataController.SavedData.inventory.GetCount(SavedDataTUType.LEVEL_IDX);
}
private void OnWinCurrency(int count, Transform fromObj)
{
WinCurrencies(count);
}
public void WinCurrencies(int count)
{
savedDataController.SavedData.inventory.AddReward(SavedDataTUType.CURRENCY, count);
savedDataController.SaveData();
onCurrenciesChanged.Invoke();
}
public long GetCurrencies()
{
return savedDataController.SavedData.inventory.GetCount(SavedDataTUType.CURRENCY);
}
public bool CanPayCost(TransactionUnit<SavedDataTUType> cost)
{
return savedDataController.SavedData.inventory.HasCost(cost);
}
public bool TryPayCost(TransactionUnit<SavedDataTUType> cost)
{
if (!savedDataController.SavedData.inventory.PayCost(cost))
{
return false;
}
onCurrenciesChanged.Invoke();
return true;
}
public void ResetData(bool exit)
{
PlayerPrefs.DeleteAll();
savedDataController.ClearData();
savedDataController.ResetData();
AppSettings.Instance.Apply();
if (exit)
{
Application.Quit();
}
}
public void DebugNextLevel()
{
savedDataController.SavedData.inventory.AddReward(SavedDataTUType.LEVEL_IDX, 1L);
savedDataController.SaveData();
onLevelChanged.Invoke();
}
public void DebugRich()
{
savedDataController.SavedData.inventory.AddReward(SavedDataTUType.CURRENCY, 1000L);
savedDataController.SaveData();
onCurrenciesChanged.Invoke();
}
public void DebugPoor()
{
savedDataController.SavedData.inventory.SetCount(SavedDataTUType.CURRENCY, 0L);
savedDataController.SaveData();
onCurrenciesChanged.Invoke();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a710c174a0bc287722435666d08f6730
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+61
View File
@@ -0,0 +1,61 @@
using UnityEngine;
using OHM.UnityToolkit;
using OHM.UnityToolkit.Vibration;
using UnityEngine.Serialization;
public class AppSettings : UniqueInstance<AppSettings>
{
[SerializeField]
public SavedDataController savedDataController;
[SerializeField]
[FormerlySerializedAs("audioManager")]
private AudioManager _audioManager;
public bool VibrationsEnabled
{
get
{
return savedDataController.SavedData.vibrationEnabled;
}
set
{
VibrationManager.Enabled = value;
savedDataController.SavedData.vibrationEnabled = value;
savedDataController.SaveData();
}
}
public bool AudioEnabled
{
get
{
return savedDataController.SavedData.soundEnabled;
}
set
{
if (_audioManager != null)
{
_audioManager.SetMasterEnabled(value);
_audioManager.SetSFXEnabled(value);
_audioManager.SetMusicEnabled(value);
}
savedDataController.SavedData.soundEnabled = value;
savedDataController.SaveData();
}
}
protected override void AwakeInstance()
{
Apply();
}
public void Apply()
{
VibrationManager.Enabled = VibrationsEnabled;
if (_audioManager != null)
{
_audioManager.Setup(AudioEnabled, AudioEnabled, AudioEnabled);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e1965773f4417a337adfe3c71eb7c4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using UnityEngine;
public interface IInputsListener
{
void InputDown(Vector3 screenPosition);
void InputMove(Vector3 screenPosition);
void InputUp();
void InputCancel();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cb496d472f2721c5cb62496134912126
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+100
View File
@@ -0,0 +1,100 @@
using UnityEngine;
using OHM.UnityToolkit;
using UnityEngine.Serialization;
public class InputController : MonoBehaviour
{
[SerializeField]
[FormerlySerializedAs("core")]
private CoreController _core;
private bool _downValid;
private Vector2 GetTouchPos()
{
if (Input.touchCount >= 1)
{
return Input.GetTouch(0).position;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.mousePosition;
#else
return Vector2.zero;
#endif
}
private bool TouchDown()
{
if (Input.touchCount >= 1)
{
return Input.GetTouch(0).phase == TouchPhase.Began;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.GetMouseButtonDown(0);
#else
return false;
#endif
}
private bool TouchHold()
{
if (Input.touchCount >= 1)
{
TouchPhase phase = Input.GetTouch(0).phase;
return phase == TouchPhase.Moved || phase == TouchPhase.Stationary;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.GetMouseButton(0);
#else
return false;
#endif
}
private bool TouchUp()
{
if (Input.touchCount >= 1)
{
return Input.GetTouch(0).phase == TouchPhase.Ended;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.GetMouseButtonUp(0);
#else
return false;
#endif
}
private void Update()
{
Vector2 touchPos = GetTouchPos();
if (!UIUtils.IsInputBlocked(touchPos) && TouchDown())
{
IInputsListener listener = _core.GetCurrentInputsListener();
if (listener != null)
{
listener.InputDown(touchPos);
}
_downValid = true;
}
else if (_downValid)
{
if (TouchHold())
{
IInputsListener listener2 = _core.GetCurrentInputsListener();
if (listener2 != null)
{
listener2.InputMove(touchPos);
}
}
else if (TouchUp())
{
_downValid = false;
IInputsListener listener3 = _core.GetCurrentInputsListener();
if (listener3 != null)
{
listener3.InputUp();
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 83511812700fa5861115d5ce6f3a28e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,170 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using OHM.UnityToolkit;
public class PerformanceManager : UniqueInstance<PerformanceManager>
{
public enum QualityLevelType
{
AUTO = 0,
MANUAL = 1
}
[Serializable]
public class QualityLevel
{
public int engineQualityLevel;
public float fixedTimeStep = 0.01f;
}
public List<QualityLevel> qualityLevels;
private AppController _app;
public float refreshRate = 1f;
public float criticalFpsThreashold;
public float lowerQualityCriticalCount = 5f;
private int _frameCount;
private float _timeAccum;
private int _criticalCount;
public int QualityIndex { get; private set; } = -1;
public QualityLevelType LevelType { get; private set; }
public bool RecordPerformances { get; private set; }
public float LastAverageFps { get; set; } = 60f;
public event Action OnQualityChange;
public event Action OnRecordingChange;
protected override void AwakeInstance()
{
base.AwakeInstance();
LevelType = QualityLevelType.AUTO;
if (qualityLevels != null && qualityLevels.Count > 0)
{
ApplyQuality(qualityLevels.Count - 1);
}
}
private void Start()
{
_app = GetComponentInParent<AppController>();
if (_app == null)
{
return;
}
_app.coreGame.onGameStarted.AddListener(StartRecord);
_app.coreGame.onGameOver.AddListener(StopRecord);
}
private void StopRecord()
{
SetRecordPerformances(record: false);
_criticalCount = 0;
}
private void StartRecord()
{
SetRecordPerformances(record: true);
}
private void ApplyQuality(int index)
{
if (QualityIndex == index)
{
return;
}
QualityIndex = index;
QualityLevel level = qualityLevels[index];
Time.fixedDeltaTime = level.fixedTimeStep;
QualitySettings.SetQualityLevel(level.engineQualityLevel, applyExpensiveChanges: true);
if (this.OnQualityChange != null)
{
this.OnQualityChange();
}
}
public void ForceQuality(int index)
{
LevelType = QualityLevelType.MANUAL;
ApplyQuality(index);
}
public void SetAutoQuality()
{
LevelType = QualityLevelType.AUTO;
if (qualityLevels != null && qualityLevels.Count > 0)
{
ApplyQuality(qualityLevels.Count - 1);
}
}
private void Update()
{
UpdatePerformances();
}
public void SetRecordPerformances(bool record)
{
RecordPerformances = record;
if (this.OnRecordingChange != null)
{
this.OnRecordingChange();
}
_criticalCount = 0;
}
private void UpdatePerformances()
{
if (!RecordPerformances || LevelType != QualityLevelType.AUTO)
{
_criticalCount = 0;
return;
}
if (QualityIndex < 1)
{
return;
}
_frameCount++;
_timeAccum += Time.unscaledDeltaTime;
if (_timeAccum <= refreshRate)
{
return;
}
LastAverageFps = _frameCount / _timeAccum;
OnNewPerfValue();
}
private void OnNewPerfValue()
{
_frameCount = 0;
_timeAccum = 0f;
if (LastAverageFps >= criticalFpsThreashold)
{
_criticalCount = 0;
return;
}
_criticalCount++;
if (_criticalCount >= lowerQualityCriticalCount)
{
LowerQuality();
_criticalCount = 0;
}
}
private void LowerQuality()
{
int index = QualityIndex - 1;
ApplyQuality(index);
Debug.Log("Lowering quality to " + index);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f72d7a86f8e495336fc2d02def50c0c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+19
View File
@@ -0,0 +1,19 @@
using System;
using UnityEngine;
[Serializable]
public class SavedData
{
[SerializeField]
public SavedDataInventory inventory = new SavedDataInventory();
[SerializeField]
public PlayerSkinsData playerSkins = new PlayerSkinsData();
[SerializeField]
public PickupsSkinsData pickupsSkins = new PickupsSkinsData();
public bool firstOpen = true;
[SerializeField]
public bool vibrationEnabled = true;
[SerializeField]
public bool soundEnabled;
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 880ef53af3dba79814b3821cefc53490
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
using OHM.UnityToolkit;
public class SavedDataController : SavedDataController<SavedData>
{
protected override void FillInitialData(SavedData initialData)
{
initialData.soundEnabled = true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a91622bd5b3585cef772d7762cfccee4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
using System;
using OHM.UnityToolkit.Inventory;
[Serializable]
public class SavedDataInventory : Inventory<SavedDataTUType>
{
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c94542420f9390e4da5b0a51d45f8038
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System;
[Serializable]
public enum SavedDataTUCategory
{
CURRENCY = 0,
SKIN = 1,
NO_AD = 2,
BEST_SCORE_DEFAULT = 10,
PLAYER_LEVEL = 11
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2d86b549d14c3cf4c89483c9a94c378c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
using System;
using OHM.UnityToolkit.Inventory;
[Serializable]
public class SavedDataTUType : TUTypeStrId<SavedDataTUCategory>
{
public static SavedDataTUType CURRENCY = new SavedDataTUType(SavedDataTUCategory.CURRENCY);
public static SavedDataTUType BEST_SCORE_DEFAULT = new SavedDataTUType(SavedDataTUCategory.BEST_SCORE_DEFAULT);
public static SavedDataTUType NO_AD = new SavedDataTUType(SavedDataTUCategory.NO_AD);
public static SavedDataTUType LEVEL_IDX = new SavedDataTUType(SavedDataTUCategory.PLAYER_LEVEL);
public SavedDataTUType(SavedDataTUCategory category, string id = "")
: base(category, id)
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1268e1cb3e9ecc343a8974227d8dfd8b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4e41afcef00cfd544a89c0e4ec1773d1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+115
View File
@@ -0,0 +1,115 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Serialization;
public class CamController : MonoBehaviour
{
[SerializeField]
public Camera cam;
[SerializeField]
[FormerlySerializedAs("smoothTime")]
private float _smoothTime = 0.2f;
[SerializeField]
[FormerlySerializedAs("houseSmoothTime")]
private float _houseSmoothTime = 0.2f;
[SerializeField]
[FormerlySerializedAs("followTargetOnX")]
private bool _followTargetOnX;
[SerializeField]
[FormerlySerializedAs("smoothFogDuration")]
private float _smoothFogDuration = 0.5f;
[SerializeField]
[FormerlySerializedAs("houseFogStartDist")]
private float _houseFogStartDist = 50f;
[SerializeField]
[FormerlySerializedAs("houseFogEndDist")]
private float _houseFogEndDist = 50f;
[SerializeField]
private Animator anim;
private Player followTarget;
private Vector3 _posVelocity;
private float _fogEndDistanceBefore;
private float _fogStartDistanceBefore;
public void Warmup()
{
base.transform.position = followTarget.transform.position;
anim.SetBool("HouseMode", value: false);
anim.SetBool("RoomMode", value: false);
anim.SetTrigger("Reset");
anim.SetFloat("CamNew", 0f);
anim.SetBool("HouseMode", value: false);
}
public void SetTarget(Player followTarget)
{
this.followTarget = followTarget;
}
public void Go()
{
anim.SetTrigger("Go");
}
public void Win(bool best)
{
anim.SetBool("BestWin", best);
anim.SetTrigger("Win");
}
public void GameOver()
{
anim.SetTrigger("GameOver");
}
public void Revive()
{
anim.SetTrigger("Revive");
}
private void FixedUpdate()
{
if (followTarget == null)
{
return;
}
Transform target = followTarget.movePlayer.toMove.transform;
float smooth = _smoothTime;
Vector3 targetPos = target.position;
if (!_followTargetOnX)
{
targetPos.x = 0f;
}
base.transform.position = Vector3.SmoothDamp(base.transform.position, targetPos, ref _posVelocity, smooth, float.PositiveInfinity, Time.deltaTime);
base.transform.rotation = followTarget.transform.rotation;
}
private IEnumerator SmoothChangeFogRoutine(bool show)
{
float from = RenderSettings.fogEndDistance;
float to = show ? _houseFogEndDist : _fogEndDistanceBefore;
for (float t = 0f; t < _smoothFogDuration; t += Time.deltaTime)
{
RenderSettings.fogEndDistance = Mathf.Lerp(from, to, t / _smoothFogDuration);
yield return null;
}
RenderSettings.fogEndDistance = to;
}
public void ShopCam(string trigger)
{
anim.ResetTrigger("ExitShop");
anim.SetTrigger(trigger);
}
public void ExitShop()
{
anim.SetTrigger("ExitShop");
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1fb2b7ab81861a2a54bcb6892a2c66e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+26
View File
@@ -0,0 +1,26 @@
using UnityEngine;
public class CoreBehaviour : MonoBehaviour
{
private CoreDef _coreDef;
protected CoreDef CoreDef
{
get
{
if (_coreDef == null)
{
CoreDefProvider provider = GetComponentInParent<CoreDefProvider>();
if (provider != null)
{
_coreDef = provider.coreDef;
}
else
{
Debug.LogError("CoreBehaviour should be a child of its CoreDefProvider");
}
}
return _coreDef;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d61ce73996a3a258ffc275c88687ec4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+341
View File
@@ -0,0 +1,341 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
using Ambiance;
using OHM.UnityToolkit.FSM;
using OHM.UnityToolkit.Pooling;
public class CoreController : CoreBehaviour
{
[SerializeField]
public CoreDef def;
[SerializeField]
public CamController cam;
[SerializeField]
public ScoreController scoreController;
[SerializeField]
private Transform dynamicCont;
[SerializeField]
public PickupSkinProvider pickupSkinProvider;
[HideInInspector]
public UnityEvent onWarmup;
[HideInInspector]
public UnityEvent onGameStarted;
[HideInInspector]
public UnityEvent onGameWon;
[HideInInspector]
public UnityEvent onGameOver;
[NonSerialized]
public List<Section> debugForcedLevel;
private List<Section> _currentLevelPrefabs;
private List<Section> previousSectionsToRemove;
[NonSerialized]
public int keyCountToSpawn;
public CoreCurrenciesController currenciesController = new CoreCurrenciesController();
private System.Random random = new System.Random();
private int _currentSeed;
public FiniteStateMachine<GameStateType> GameStateMachine = new FiniteStateMachine<GameStateType>();
public GameStateType GS_WARMUP;
public GameStateType GS_STARTED;
public GameStateType GS_WON;
public GameStateType GS_GAME_OVER;
public float progressionRatio;
private Coroutine _warmupCoroutine;
private PlayerSkinDef _playerSkinDef;
public List<Section> CurrentSections { get; private set; }
public int CurrentSectionIndex { get; private set; }
public List<Section> CurrentLevelPrefabs => _currentLevelPrefabs;
public long CurrentLevelIdx { get; private set; }
public Player CurrentPlayer { get; private set; }
public static event Action<Section, int, int> OnSectionCreated;
public void Awake()
{
GS_WARMUP = new GameStateType
{
startAction = EnterWarmup
};
GS_STARTED = new GameStateType
{
startAction = EnterGame,
updateAction = GameUpdate,
getInputsListenerFunc = GameGetInputsListener
};
GS_WON = new GameStateType
{
startAction = EnterWon
};
GS_GAME_OVER = new GameStateType
{
startAction = EnterGameOver
};
GameStateMachine = new FiniteStateMachine<GameStateType>();
}
private void Update()
{
GameStateMachine.Update();
}
public void Warmup(long levelIdx)
{
bool levelChanged = CurrentLevelIdx != levelIdx;
if (levelChanged)
{
previousSectionsToRemove = ((def.GetProgression().removePreviousSectionsForNextGame && _currentLevelPrefabs != null) ? new List<Section>(_currentLevelPrefabs) : null);
}
int seed;
if (!levelChanged && def.GetProgression().replaySameLevelsAfterGameOver)
{
seed = _currentSeed;
}
else
{
seed = (_currentSeed = random.Next());
}
random = new System.Random(seed);
CurrentLevelIdx = levelIdx;
GameStateMachine.SetState(GS_WARMUP);
}
private void EnterWarmup()
{
Cleanup();
SetupAmbiance();
if (_warmupCoroutine != null)
{
StopCoroutine(_warmupCoroutine);
}
_warmupCoroutine = StartCoroutine(WarmupCoroutine());
}
private IEnumerator WarmupCoroutine()
{
yield return new WaitForEndOfFrame();
GenerateLevel();
yield return CreateCurrentSection();
CurrentPlayer = CreatePlayer();
scoreController.InitScore(CurrentPlayer.richManagePlayer.curScore);
cam.Warmup();
onWarmup.Invoke();
}
public void ChangeRichValueStartRV()
{
CurrentPlayer.richManagePlayer.SetRichPoorValue(base.CoreDef.player.richValueStartABTestStartRich, true);
}
private void SetupAmbiance()
{
int levelIdx = (int)CurrentLevelIdx;
AmbianceController.Instance.SetLevelIdx(levelIdx, onFire: false, forceReload: true);
}
private void Cleanup()
{
scoreController.Reset();
currenciesController.Reset();
CurrentSections = new List<Section>();
CurrentPlayer = null;
PoolsManager.ReleaseAllPooledChildren(dynamicCont);
var children = new List<Transform>();
foreach (Transform child in dynamicCont)
{
children.Add(child);
}
foreach (Transform child in children)
{
PoolsManager.ReleaseObject(child.gameObject);
}
}
public bool IsReadyToPlay()
{
return CurrentPlayer != null && CurrentPlayer.IsReady;
}
public void GenerateLevel()
{
List<Section> generated = LevelGenerator.GenerateLevel(base.CoreDef, CurrentLevelIdx, random, debugForcedLevel, previousSectionsToRemove);
debugForcedLevel = null;
CurrentSectionIndex = 0;
_currentLevelPrefabs = CreateAllSection(generated);
}
private Section CreateSection(Section prefab, Transform pos)
{
Section section = UnityEngine.Object.Instantiate(prefab, dynamicCont);
section.Setup(base.CoreDef);
if (pos != null)
{
section.transform.position = pos.position;
section.transform.rotation = pos.rotation;
}
CurrentSections.Add(section);
return section;
}
private List<Section> CreateAllSection(List<Section> sectionsPrefabs)
{
var result = new List<Section>();
bool turnRight = UnityEngine.Random.Range(0, 1) == 0;
ProgressionDef progression = def.GetProgression();
bool useTurn = progression.useTurn;
int sinceTurn = 0;
for (int i = 0; i < sectionsPrefabs.Count; i++)
{
result.Add(sectionsPrefabs[i]);
if (useTurn && i != 0 && i < sectionsPrefabs.Count - 2 && sinceTurn >= progression.turnEachSection)
{
result.Add(turnRight ? progression.GroundRight : progression.GroundLeft);
result.Add(progression.SafeZone);
sinceTurn = 0;
turnRight = !turnRight;
}
sinceTurn++;
}
return result;
}
private IEnumerator CreateCurrentSection()
{
Transform pos = null;
for (int i = 0; i < _currentLevelPrefabs.Count; i++)
{
Section section = CreateSection(_currentLevelPrefabs[i], pos);
yield return new WaitForEndOfFrame();
pos = section.endLevel;
}
yield return new WaitForEndOfFrame();
}
private Player CreatePlayer()
{
Player player = UnityEngine.Object.Instantiate(_playerSkinDef.prefab, dynamicCont);
player.transform.position = Vector3.zero;
player.onWin = (Action<int>)Delegate.Combine(player.onWin, new Action<int>(Win));
player.onLose = (Action)Delegate.Combine(player.onLose, new Action(GameOver));
player.richManagePlayer.onUpdateScore += OnUpdateScore;
cam.SetTarget(player);
return player;
}
public void SetPlayerSkin(PlayerSkinDef skin)
{
_playerSkinDef = skin;
if (CurrentPlayer == null)
{
return;
}
bool wasShopMode = CurrentPlayer.ShopMode;
UnityEngine.Object.Destroy(CurrentPlayer.gameObject);
CurrentPlayer = CreatePlayer();
if (wasShopMode)
{
CurrentPlayer.ShopSkinMode();
}
}
public void Go()
{
if (IsReadyToPlay())
{
CurrentPlayer.Go();
onGameStarted.Invoke();
GameStateMachine.SetState(GS_STARTED);
}
}
private void EnterGame()
{
UnityEngine.Debug.Log("Enter Game");
cam.Go();
}
private void GameUpdate()
{
}
private IInputsListener GameGetInputsListener()
{
return CurrentPlayer.movePlayer.swerveInput;
}
private void OnUpdateScore(long score)
{
scoreController.UpdateScore(score, CurrentPlayer.movePlayer.transform, ScoreController.ScoreType.DEFAULT_SCORE);
}
private void Win(int multCurrency)
{
scoreController.SetMultCurrency(multCurrency);
cam.Win(true);
GameStateMachine.SetState(GS_WON);
}
private void EnterWon()
{
UnityEngine.Debug.Log("VICTORY");
onGameWon.Invoke();
}
public void WinCurrencies()
{
currenciesController.WinCurrency((int)scoreController.Score, CurrentPlayer.movePlayer.transform);
}
public void WinCurrenciesRaw(int rawValue)
{
currenciesController.WinCurrency(rawValue, CurrentPlayer.movePlayer.transform);
}
private void GameOver()
{
cam.GameOver();
GameStateMachine.SetState(GS_GAME_OVER);
}
private void EnterGameOver()
{
UnityEngine.Debug.Log("GAME OVER");
onGameOver.Invoke();
}
public IInputsListener GetCurrentInputsListener()
{
Func<IInputsListener> func = GameStateMachine.CurrentState?.getInputsListenerFunc;
return (func != null) ? func() : null;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 852b7e7f53808d1713022e11f3867cd1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using System;
using UnityEngine;
public class CoreCurrenciesController
{
public CoreCurrenciesDef Def { get; private set; }
public int CurrenciesWon { get; private set; }
public bool CurrenciesMultiplied { get; private set; }
public event Action<int, Transform> onWinCurrencies;
public event Action onMultiplyCurrencies;
public void Setup(CoreCurrenciesDef def)
{
Def = def;
}
public void Reset()
{
CurrenciesWon = 0;
CurrenciesMultiplied = false;
}
public void WinCurrency(int count, Transform from)
{
CurrenciesWon += count;
if (this.onWinCurrencies != null)
{
this.onWinCurrencies(count, from);
}
}
public void MultiplyCurrencies(Transform from)
{
if (CurrenciesMultiplied)
{
return;
}
int multiplier = Def.currencyMultiplier;
int before = CurrenciesWon;
CurrenciesWon = multiplier * before;
if (this.onWinCurrencies != null)
{
this.onWinCurrencies((multiplier - 1) * before, from);
}
CurrenciesMultiplied = true;
if (this.onMultiplyCurrencies != null)
{
this.onMultiplyCurrencies();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 644151d01a5601c503d45292c9b9faae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
using System;
[Serializable]
public class CoreCurrenciesDef
{
public int currencyMultiplier;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a9b8a46e988c53040b79adc9f608c69c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+92
View File
@@ -0,0 +1,92 @@
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;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9c69e165e588b999a307f701cc465be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
using UnityEngine;
public class CoreDefProvider : MonoBehaviour
{
public CoreDef coreDef;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 566646172f469626a847b3bfba33ac4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
using System;
using OHM.UnityToolkit;
[Serializable]
public class DifficultyPoolElem : RandomPoolElement<int>
{
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b028f39ddaa9a848bdfae81aba41706
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
using System;
using OHM.UnityToolkit.FSM;
public class GameStateType : StateBase<GameStateType>
{
public Func<IInputsListener> getInputsListenerFunc;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0411764e0bdb459409c15b8159c63773
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Debug = UnityEngine.Debug;
using OHM.UnityToolkit;
public static class LevelGenerator
{
public static List<Section> GenerateLevel(CoreDef def, long levelIdx, Random random, List<Section> forceLevel, List<Section> previousSections)
{
var result = new List<Section>();
ProgressionDef progression = def.GetProgression();
if (progression.initialSection != null)
{
result.Add(progression.initialSection);
}
if (forceLevel != null && forceLevel.Count >= 1)
{
result.AddRange(forceLevel);
}
else
{
result.AddRange(GetLevelSectionList(def, levelIdx, random, previousSections));
}
Section final = progression.finalSectionABTest;
if (final != null)
{
result.Add(final);
}
return result;
}
private static List<Section> GetLevelSectionList(CoreDef def, long levelIdx, Random random, List<Section> sectionsToAvoid)
{
ProgressionDef progression = def.GetProgression();
LevelDef level = def.GetLevel(levelIdx);
var pool = new List<Section>(progression.sections);
var result = new List<Section>();
if (sectionsToAvoid != null && sectionsToAvoid.Count >= 1)
{
pool.RemoveAll((Section s) => sectionsToAvoid.Contains(s));
}
foreach (Section forced in level.forcedSections)
{
if (forced != null)
{
result.Add(forced);
pool.Remove(forced);
}
}
for (int i = result.Count; i < level.sectionCount; i++)
{
Section drawn = DrawSection(level, def, i, levelIdx, pool, random, level.maxSectionYPerLevel);
if (drawn != null)
{
result.Add(drawn);
pool.Remove(drawn);
}
}
return result;
}
private static Section DrawSection(LevelDef level, CoreDef coreDef, int index, long levelIdx, List<Section> currentSectionsPool, Random random, int maxSectionYPerLevel)
{
var diffPool = new List<DifficultyPoolElem>(
(level.randomDiffPoolAlt != null && level.randomDiffPoolAlt.Count >= 1 && index % 2 == 1)
? level.randomDiffPoolAlt
: level.randomDiffPool);
if (maxSectionYPerLevel <= 0)
{
foreach (DifficultyPoolElem elem in new List<DifficultyPoolElem>(diffPool))
{
List<Section> match = currentSectionsPool.Where((Section s) => s.difficulty == elem.element).ToList();
if (match.Count >= 1 && match[0].differentPath)
{
diffPool.Remove(elem);
}
}
}
int difficulty = RandomPoolUtils.DrawElementFromPool<DifficultyPoolElem, int>(random, diffPool);
List<Section> candidates = currentSectionsPool.Where((Section s) => s.difficulty == difficulty).ToList();
if (candidates.Count != 0)
{
return RandomExtensions.ListElem(random, candidates);
}
Debug.LogFormat("No more section with diff {0}", difficulty);
List<Section> fallback = currentSectionsPool.Where((Section s) => s.difficulty != difficulty).ToList();
if (fallback.Count == 0)
{
return null;
}
Debug.LogWarningFormat("No section with difficulty {0} found, referenced in level {1}. Will use random other difficulty.", difficulty, levelIdx);
return RandomExtensions.ListElem(random, fallback);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 396d866662b9cbc778a7b07df4c43850
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.Events;
public class ScoreController : CoreBehaviour
{
public enum ScoreType
{
DEFAULT_SCORE = 0
}
public class ScoreEvent : UnityEvent<int, Transform, ScoreType>
{
}
[HideInInspector]
public ScoreEvent onScore = new ScoreEvent();
public long Score { get; private set; }
public int multCurrency { get; private set; }
public void Setup()
{
Score = 0L;
}
public void InitScore(long score)
{
Score = score;
}
public void UpdateScore(long score, Transform obj, ScoreType type)
{
long delta = score - Score;
if (delta != 0L)
{
Score = score;
onScore.Invoke((int)delta, obj, type);
}
}
public void IncScore(long inc, Transform obj, ScoreType type)
{
Score += inc;
onScore.Invoke((int)inc, obj, type);
}
public void SetMultCurrency(int mult)
{
multCurrency = mult;
Score *= mult;
}
public void Reset()
{
Score = 0L;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86d8ca6254653a88aa4884b95654e6ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+94
View File
@@ -0,0 +1,94 @@
using System.Collections.Generic;
using UnityEngine;
public class Section : CoreBehaviour
{
public int difficulty;
public Transform endLevel;
public bool differentPath;
public bool V_1_1;
public bool V_1_6;
public int sectionCountNormalSection = 1;
public bool containIngameAds = true;
public void Setup(CoreDef def)
{
}
[ContextMenu("TEST")]
public void Test()
{
TestSection(this);
}
public static void TestSection(Section b)
{
AppController app = Object.FindObjectOfType<AppController>();
if (!(app == null))
{
CoreController core = app.coreGame;
var forced = new List<Section> { b };
if (core != null)
{
core.debugForcedLevel = forced;
}
}
}
private static float WrapAngle(float angle)
{
angle %= 360f;
if (angle > 180f)
{
angle -= 360f;
}
return angle;
}
public float GetYRotationTurnSection(Vector3 pos, float curYRot, MovePlayer moveP)
{
float t = 0f;
if (moveP.verti)
{
float from = base.transform.position.z;
float to = endLevel.transform.position.z;
if (from != to)
{
float r = (pos.z - from) / (to - from);
if (r >= 0f)
{
t = Mathf.Min(r, 1f);
}
}
}
else
{
float from = base.transform.position.x;
float to = endLevel.transform.position.x;
if (from != to)
{
float r = (pos.x - from) / (to - from);
if (r >= 0f)
{
t = Mathf.Min(r, 1f);
}
}
}
float targetY = WrapAngle(endLevel.transform.eulerAngles.y);
if (t >= 0.99f)
{
moveP.EndTurn();
return targetY;
}
return curYRot + Mathf.Max(t, 0f) * (targetY - curYRot);
}
public Vector3 GetPosTurnSection(Vector3 pos, float curYRot, Player p)
{
return Vector3.zero;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c58648476830a0ac7dc699198dd29ebc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 37ceee94b3f90f24aac5cffc973a4775
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+24
View File
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class LevelDef
{
public int levelCount;
[Tooltip("Section")]
[Space]
public int sectionCount;
public int maxSectionYPerLevel = 1;
[Tooltip("Random Difficluty Pool")]
public List<DifficultyPoolElem> randomDiffPool;
[Tooltip("Atlernate Random Difficluty Pool (leave empty to not use)")]
public List<DifficultyPoolElem> randomDiffPoolAlt;
[Space]
[Tooltip("Forced section : the final one will always be added")]
public List<Section> forcedSections;
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 90167e2bf6b774c4a982e015442043dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+10
View File
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "MetaDef", menuName = "GameSqueleton/New Meta Game Def")]
public class MetaDef : ScriptableObject
{
public List<PlayerSkinDef> playerSkins;
public List<PickupsSkinDef> pickupsSkins;
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9721b3e8f85cfffc8751e8c69b2a537c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "ProgressionDef", menuName = "GameSqueleton/New Progression Def")]
public class ProgressionDef : ScriptableObject
{
public bool replaySameLevelsAfterGameOver = true;
public bool removePreviousSectionsForNextGame;
[Space]
public bool useTurn;
public int turnEachSection = 1;
public Section GroundLeft;
public Section GroundRight;
public Section SafeZone;
[Header("Checkpoints")]
[Space]
public GameObject Checkpoints;
[Header("Bonus Levels")]
[Space]
[Header("Levels Progression")]
[Space]
public List<LevelDef> levels = new List<LevelDef>();
public List<LevelDef> levelsShorter = new List<LevelDef>();
public List<LevelDef> levelsDiffPath = new List<LevelDef>();
[Header("Sections")]
public Section initialSection;
public Section finalSection;
public Section finalSectionABTest;
[Space]
public List<Section> sections;
public List<string> sectionDirs = new List<string> { "Assets/Prefabs/Sections" };
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e35a105ac4137e628f4bd6e8aa6e1e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+16
View File
@@ -0,0 +1,16 @@
using UnityEngine;
using OHM.UnityToolkit.Localization;
using UnityEngine.Serialization;
public class SizePrefabUI : MonoBehaviour
{
[SerializeField]
[FormerlySerializedAs("locText")]
private LocalizedText _locText;
public void SetText(string locKey, Color color)
{
_locText.ChangeKey(locKey);
_locText.text.tmTexts[0].color = color;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 492c9a28e131cd630858169212e4d60f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 63f2b1c6f8f6ca849b441c20f0da88cf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+21
View File
@@ -0,0 +1,21 @@
using System;
[Serializable]
public class AI
{
public float distWithTargerWayPoint;
public float rotationSpeed;
public float acceleration;
public float maxSpeed;
public int minRichLevelToPickpocket;
public int minRichLevelToPhotograph;
public int valueToSteal;
public int valueToWin;
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3aebac5537b765e489479441332d02fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+66
View File
@@ -0,0 +1,66 @@
using UnityEngine;
using OHM.UnityToolkit;
using UnityEngine.Serialization;
public class AIBase : CoreBehaviour
{
public bool isPhotographer;
public float TimeWaitBeforeMove;
[SerializeField]
private Animator anim;
[SerializeField]
private GameObject visual;
[SerializeField]
private MovingPlatforme MovingPlatforme;
[SerializeField]
[FormerlySerializedAs("soundFX")]
private SFX _soundFX;
private CoreController coreController;
private Vector3 startRot;
private Vector3 _inverseStartRot;
private Vector3 lastPos;
public bool isActive { get; private set; }
private void Awake()
{
}
private void Start()
{
}
private void OnDestroy()
{
}
private void Update()
{
}
public void StopAI()
{
}
public bool PlayerIsCatch(RichManagePlayer richManagePlayer, Rigidbody body)
{
return false;
}
private void SetDirLookAt(Vector3 dir)
{
}
public void OnRevive()
{
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eea076fac044e2ba387270490f6857c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+31
View File
@@ -0,0 +1,31 @@
using UnityEngine;
public class Checkpoints : CoreBehaviour
{
private Animator anim;
public bool isPass { get; private set; }
private void Start()
{
InstantiatePrefab();
}
private void InstantiatePrefab()
{
GameObject instance = UnityEngine.Object.Instantiate(base.CoreDef.GetProgression().Checkpoints, base.transform);
if (instance != null)
{
anim = instance.GetComponent<Animator>();
}
}
public void PassCheckpoint()
{
isPass = true;
if (anim != null)
{
anim.SetBool("Pass", value: true);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d691d1648b8ee01733ca745de1a32df8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
using UnityEngine;
public class ConutinuePickUpZone : MonoBehaviour
{
public TypeItem typeItem;
public MeshRenderer mesh;
public Material normMat;
public Material activeMat;
public void ActiveZone(bool active)
{
mesh.material = (active ? activeMat : normMat);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a0eb8d5bc649e87f8819d3aadd4edb40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+20
View File
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using UnityEngine;
public class Doors : MonoBehaviour
{
private List<PickUpItem> pickUpItems = new List<PickUpItem>();
public void AddDoor(PickUpItem item)
{
pickUpItems.Add(item);
}
public void DisableDoors()
{
foreach (PickUpItem item in pickUpItems)
{
item.UseDependenceItem();
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0e4f6d50787222892851c2fbcd95fe39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,4 @@
public interface ILevelLocked
{
long GetUnlockLevel();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b573b66f006bb9c448b4a3746e656e74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,139 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
public class MovingPlatforme : CoreBehaviour
{
[Header("Move Position")]
public float moveDuration;
[SerializeField]
[FormerlySerializedAs("moveDelta")]
private Vector3 _moveDelta;
[SerializeField]
[FormerlySerializedAs("moveCurve")]
private AnimationCurve _moveCurve;
[Header("Move Rotation")]
[Space(3f)]
public float moveRotationDuration;
[SerializeField]
[FormerlySerializedAs("rotationDelta")]
private Vector3 _rotationDelta;
[Space(3f)]
[Header("General")]
[SerializeField]
[FormerlySerializedAs("local")]
private bool _local;
[SerializeField]
[FormerlySerializedAs("delayBeforeStart")]
private float _delayBeforeStart;
[SerializeField]
[FormerlySerializedAs("triggerMoving")]
private TriggerMovingPlatforme _triggerMoving;
[SerializeField]
[FormerlySerializedAs("pingpong")]
private bool _pingpong = true;
[SerializeField]
[FormerlySerializedAs("oneLoop")]
private bool _oneLoop;
private Vector3 _p1;
private Vector3 P2;
private Quaternion _r1;
private Quaternion R2;
private Vector3 rotationSpeed;
private bool _inverseRot;
private Rigidbody _bodyToMove;
private float _currentTimeDelay;
private float _currentTimeMove;
private float _currentTimeMoveRotation;
private float _currentTimeMoveRotationPingPong;
private bool _isInit;
private Vector3 _startPos;
private Quaternion startRot;
private List<AIBase> _listAIAttch = new List<AIBase>();
private float _ratio;
private bool _needRotate = true;
private bool _curR;
public bool Started { get; private set; }
public Vector3 curLookDir { get; private set; }
public Vector3 curLookDir1 { get; private set; }
public Vector3 curLookDir2 { get; private set; }
public bool needInverseRot => false;
public void AttachAI(AIBase ai)
{
}
public void StopAllAI()
{
}
private void Awake()
{
}
private void Start()
{
}
public void ResetMovingPlatform()
{
}
public void ActivatePlateforme(bool active)
{
}
public void Activate(bool active)
{
}
private Vector3 GetGlobalPosition(Vector3 p)
{
return default(Vector3);
}
private Quaternion GetGlobalRotation(Quaternion r)
{
return default(Quaternion);
}
private void FixedUpdate()
{
}
private void OnDrawGizmos()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c92eac4f79bf31f56367818c3dc233a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+200
View File
@@ -0,0 +1,200 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
public class PickUpItem : MonoBehaviour
{
public bool specialPickupEnd;
[SerializeField]
[FormerlySerializedAs("skinnable")]
private bool _skinnable = true;
[SerializeField]
[FormerlySerializedAs("rotationObject")]
private bool _rotationObject = true;
[SerializeField]
private GameObject visual;
[SerializeField]
[FormerlySerializedAs("visual_ABTest")]
private GameObject _visual_ABTest;
[SerializeField]
[FormerlySerializedAs("door")]
private GameObject _door;
[SerializeField]
[FormerlySerializedAs("doorsScript")]
private Doors _doorsScript;
[SerializeField]
private bool AB_test_tandom;
[SerializeField]
[FormerlySerializedAs("rdmVisual")]
private List<GameObject> _rdmVisual;
[SerializeField]
[FormerlySerializedAs("rdmVisualSafe")]
private List<GameObject> _rdmVisualSafe;
[SerializeField]
private float rotationSpeed;
[SerializeField]
[FormerlySerializedAs("dependenceItem")]
private PickUpItem _dependenceItem;
[SerializeField]
[FormerlySerializedAs("hasItemsNoSafe")]
private bool _hasItemsNoSafe = true;
[SerializeField]
private Transform instanceCont;
public TypeItem typeItem;
public float valueChange;
public static bool DebugItemNoSafeEnabled = true;
private GameObject _visualInstance;
private PickupSkinProvider _skinProvider;
private CoreController coreController;
public bool isUse { get; private set; }
private void Awake()
{
if (_skinnable)
{
_skinProvider = GetComponentInParent<PickupSkinProvider>();
if (_skinProvider != null)
{
_skinProvider.onSkinChanged += ApplySkin;
ApplySkin();
}
}
coreController = GetComponentInParent<CoreController>();
if (coreController != null)
{
}
if (_doorsScript != null)
{
_doorsScript.AddDoor(this);
}
if (_visual_ABTest != null)
{
_visual_ABTest.SetActive(value: true);
}
}
private void ApplySkin()
{
if (_visualInstance != null)
{
Object.Destroy(_visualInstance.gameObject);
_visualInstance = null;
}
GameObject prefab = null;
if (_skinnable && _skinProvider != null)
{
prefab = _skinProvider.GetSkin(typeItem);
}
if (prefab == null)
{
List<GameObject> list = ((DebugItemNoSafeEnabled && _hasItemsNoSafe) ? _rdmVisual : _rdmVisualSafe);
if (_rdmVisual != null && _rdmVisual.Count >= 1)
{
prefab = list[Random.Range(0, list.Count)];
}
}
if (prefab != null)
{
_visualInstance = Object.Instantiate(prefab, instanceCont);
}
}
private void OnDestroy()
{
if (_skinProvider != null)
{
_skinProvider.onSkinChanged -= ApplySkin;
}
if (coreController != null)
{
}
}
private void OnRevive()
{
PickUpItem item = this;
while (item.isUse)
{
item.ResetItem();
if (!(item._dependenceItem != null))
{
break;
}
item = item._dependenceItem;
}
}
private void ResetItem()
{
isUse = false;
visual.SetActive(value: true);
if (_visual_ABTest != null)
{
_visual_ABTest.SetActive(value: true);
}
if (_door != null)
{
_door.SetActive(value: true);
}
}
public void ReviveDependenceItem()
{
if (isUse)
{
ResetItem();
}
}
private void Update()
{
if (!isUse && _rotationObject)
{
visual.transform.Rotate(Vector3.up * rotationSpeed * Time.deltaTime);
}
}
public void UseDependenceItem()
{
isUse = true;
visual.SetActive(value: false);
if (_visual_ABTest != null)
{
_visual_ABTest.SetActive(value: false);
}
if (_door != null)
{
_door.SetActive(value: false);
}
}
public void UseItem()
{
isUse = true;
visual.SetActive(value: false);
if (_visual_ABTest != null)
{
_visual_ABTest.SetActive(value: false);
}
if (_door != null)
{
_door.SetActive(value: false);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dba0f559f8bf5f62283f8571f223dbd1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using System;
using UnityEngine;
public class PickupSkinProvider : MonoBehaviour
{
private PickupsSkinDef _skin;
public event Action onSkinChanged;
public void SetSkin(PickupsSkinDef newSkin)
{
PickupsSkinDef previous = _skin;
_skin = newSkin;
if (newSkin != previous && this.onSkinChanged != null)
{
this.onSkinChanged();
}
}
public GameObject GetSkin(TypeItem type)
{
switch (type)
{
case TypeItem.Rich:
return _skin.prefabGood;
case TypeItem.Poor:
return _skin.prefabBad;
default:
return null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1bf17e88432b931e3545fe0956e66d4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
public class RandomAudioWithDelay : MonoBehaviour
{
[SerializeField]
[FormerlySerializedAs("source")]
private AudioSource _source;
[SerializeField]
public List<AudioClip> randomClips;
[SerializeField]
public float minDelay;
private float _lastPlayTime = -1f;
private float _ratioMinDelay = 1f;
private System.Random random;
private void Awake()
{
random = new System.Random();
}
public void PlayNext()
{
if (Time.time <= _lastPlayTime + minDelay * _ratioMinDelay)
{
return;
}
_lastPlayTime = Time.time;
AudioClip clip = OHM.UnityToolkit.RandomExtensions.ListElem(random, randomClips);
if (clip != null)
{
_source.PlayOneShot(clip);
}
}
public void SetRatioMinDelay(float ratio)
{
_ratioMinDelay = ratio;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: abdbd1de1e89ca0e5e23353a317b2280
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using UnityEngine;
public class RandomSpawnItems : MonoBehaviour
{
public PickUpItem prefabPositifItem;
public PickUpItem prefabNegatifItem;
public Vector2 minMaxItem;
public int positifItemPrct;
private List<Transform> _listSpawn;
private void Awake()
{
_listSpawn = new List<Transform>(GetComponentsInChildren<Transform>());
_listSpawn.Remove(base.transform);
int total = (int)UnityEngine.Random.Range(minMaxItem.x, minMaxItem.y);
int positif = (int)((float)total * (float)positifItemPrct / 100f);
CreateItems(positif, prefabPositifItem);
CreateItems(total - positif, prefabNegatifItem);
}
private void CreateItems(int nbr, PickUpItem prefab)
{
for (int i = 0; i < nbr; i++)
{
if (_listSpawn.Count < 1)
{
break;
}
int idx = UnityEngine.Random.Range(0, _listSpawn.Count);
PickUpItem item = UnityEngine.Object.Instantiate(prefab, _listSpawn[idx]);
if (item != null)
{
item.gameObject.name = prefab.name + i;
item.specialPickupEnd = true;
}
_listSpawn.RemoveAt(idx);
}
}
}

Some files were not shown because too many files have changed in this diff Show More