2022-01-17 17:49:27 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
public class DataHolder : MonoBehaviour
|
|
|
|
{
|
|
|
|
public static DataHolder main;
|
|
|
|
public List<BattleConfig> easyLevels;
|
|
|
|
public List<BattleConfig> normalLevels;
|
|
|
|
public List<BattleConfig> hardLevels;
|
2022-01-19 20:27:33 +03:00
|
|
|
|
2022-01-18 22:10:57 +03:00
|
|
|
public List<GameObject> PlayerEquipment = new List<GameObject>();
|
2022-01-19 20:27:33 +03:00
|
|
|
public List<GameObject> AllEquipment = new List<GameObject>();
|
2022-01-17 17:49:27 +03:00
|
|
|
|
|
|
|
public MissionConfig mission;
|
|
|
|
[SerializeField] private string _currentScene;
|
2022-01-20 02:46:04 +03:00
|
|
|
public bool warning = true;
|
|
|
|
|
2022-01-17 17:49:27 +03:00
|
|
|
private int score = 10;
|
|
|
|
|
|
|
|
|
|
|
|
public enum complexityLevels
|
|
|
|
{
|
|
|
|
easy,
|
|
|
|
normal,
|
|
|
|
hard,
|
|
|
|
all
|
|
|
|
};
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
if(_currentScene == null)
|
|
|
|
{
|
|
|
|
Debug.LogError("WARNING! _currentScene in DataHolder not found");
|
|
|
|
}
|
|
|
|
if (main != null && main != this)
|
|
|
|
{
|
|
|
|
Debug.LogWarning("2 dataholders on the scene");
|
|
|
|
Destroy(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
main = this;
|
|
|
|
}
|
2022-01-20 02:46:04 +03:00
|
|
|
|
2022-01-17 17:49:27 +03:00
|
|
|
public void SetScore(int _newScore)
|
|
|
|
{
|
|
|
|
score = _newScore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GetScore()
|
|
|
|
{
|
|
|
|
return score;
|
|
|
|
}
|
|
|
|
public void ChangeScene(string _sceneName)
|
|
|
|
{
|
|
|
|
SceneManager.LoadScene(_sceneName, LoadSceneMode.Additive);
|
|
|
|
SceneManager.UnloadSceneAsync(_currentScene);
|
|
|
|
_currentScene = _sceneName;
|
|
|
|
}
|
|
|
|
//RANDOM LEVELS BLOCK
|
|
|
|
public BattleConfig RandomLevel(complexityLevels _complexity)
|
|
|
|
{
|
|
|
|
switch (_complexity)
|
|
|
|
{
|
|
|
|
case complexityLevels.easy:
|
|
|
|
return RandomEasyLevel();
|
|
|
|
case complexityLevels.normal:
|
|
|
|
return RandomNormalLevel();
|
|
|
|
case complexityLevels.hard:
|
|
|
|
return RandomHardLevel();
|
|
|
|
default:
|
|
|
|
return RandomAllLevel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private BattleConfig RandomEasyLevel()
|
|
|
|
{
|
|
|
|
return easyLevels[Random.Range(0, easyLevels.Count)];
|
|
|
|
}
|
|
|
|
private BattleConfig RandomNormalLevel()
|
|
|
|
{
|
|
|
|
return normalLevels[Random.Range(0, normalLevels.Count)]; ;
|
|
|
|
}
|
|
|
|
private BattleConfig RandomHardLevel()
|
|
|
|
{
|
|
|
|
return hardLevels[Random.Range(0, hardLevels.Count)];
|
|
|
|
|
|
|
|
}
|
|
|
|
private BattleConfig RandomAllLevel()
|
|
|
|
{
|
|
|
|
int _maxNumber = Random.Range(0,
|
|
|
|
easyLevels.Count + normalLevels.Count + hardLevels.Count);
|
|
|
|
if (_maxNumber < easyLevels.Count)
|
|
|
|
{
|
|
|
|
Debug.Log(_maxNumber);
|
|
|
|
return easyLevels[_maxNumber];
|
|
|
|
}
|
|
|
|
else if (_maxNumber - easyLevels.Count < normalLevels.Count)
|
|
|
|
{
|
|
|
|
|
|
|
|
return normalLevels[_maxNumber - easyLevels.Count];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return hardLevels[_maxNumber - easyLevels.Count - normalLevels.Count];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//RANDOM LEVELS BLOCK END
|
|
|
|
|
|
|
|
public void NewMission(MissionConfig _mission)
|
|
|
|
{
|
|
|
|
mission = _mission;
|
2022-01-20 11:44:38 +03:00
|
|
|
|
2022-01-17 17:49:27 +03:00
|
|
|
}
|
2022-01-20 02:46:04 +03:00
|
|
|
|
2022-01-17 17:49:27 +03:00
|
|
|
|
|
|
|
public void ReturnInMainMenu()
|
|
|
|
{
|
|
|
|
ChangeScene("MainMenu");
|
|
|
|
}
|
2022-01-19 20:27:33 +03:00
|
|
|
|
2022-01-20 02:46:04 +03:00
|
|
|
public void AddEquipmentToPlayerInventory(GameObject _item)
|
2022-01-19 20:27:33 +03:00
|
|
|
{
|
|
|
|
AllEquipment.Add(_item);
|
|
|
|
}
|
2022-01-17 17:49:27 +03:00
|
|
|
}
|