diff --git a/Assets/GlobalConfig.asset b/Assets/GlobalConfig.asset new file mode 100644 index 0000000..c75214d --- /dev/null +++ b/Assets/GlobalConfig.asset @@ -0,0 +1,23 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 32e788fd2a7bdaf4ab145b64231cb833, type: 3} + m_Name: GlobalConfig + m_EditorClassIdentifier: + enemyBaseDamage: 1 + enemyBaseLife: 5 + enemyBaseRange: 1 + enemyBaseAttackSpeed: 1 + damageFlashIntensity: 1 + harvestDuration: 1 + harvestAmount: 1 + harvestRandomDurationMinimum: 0 + harvestRandomDurationMaximum: 0 diff --git a/Assets/GlobalConfig.asset.meta b/Assets/GlobalConfig.asset.meta new file mode 100644 index 0000000..0245198 --- /dev/null +++ b/Assets/GlobalConfig.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 132e291fc51a8f445b1183b11a5d6b39 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/LevelManager.prefab b/Assets/Prefabs/LevelManager.prefab index 71fb6cb..b10ca1a 100644 --- a/Assets/Prefabs/LevelManager.prefab +++ b/Assets/Prefabs/LevelManager.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 3028288566889208750} - component: {fileID: 3028288566889208749} - component: {fileID: -245230096461627285} + - component: {fileID: 5626804684391367242} m_Layer: 0 m_Name: LevelManager m_TagString: Untagged @@ -119,3 +120,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 37c0aa967043d974783120d6ea9b136c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &5626804684391367242 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3028288566889208744} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8f878516c4a3324aa1a9672f8b336c9, type: 3} + m_Name: + m_EditorClassIdentifier: + _current: {fileID: 11400000, guid: 132e291fc51a8f445b1183b11a5d6b39, type: 2} diff --git a/Assets/Scripts/General/GlobalConfig.cs b/Assets/Scripts/General/GlobalConfig.cs new file mode 100644 index 0000000..4135a7b --- /dev/null +++ b/Assets/Scripts/General/GlobalConfig.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +public class GlobalConfig : SingletonBehaviour +{ + [SerializeField] + private GlobalConfigFile _current; + public GlobalConfigFile Current => _current; +} diff --git a/Assets/Scripts/General/GlobalConfig.cs.meta b/Assets/Scripts/General/GlobalConfig.cs.meta new file mode 100644 index 0000000..43d6acb --- /dev/null +++ b/Assets/Scripts/General/GlobalConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c8f878516c4a3324aa1a9672f8b336c9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/General/GlobalConfigFile.cs b/Assets/Scripts/General/GlobalConfigFile.cs new file mode 100644 index 0000000..94612de --- /dev/null +++ b/Assets/Scripts/General/GlobalConfigFile.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + + +[CreateAssetMenu(menuName = project_name + "/Global Config")] +public class GlobalConfigFile : ScriptableObject +{ + public const string project_name = "Gather And Defend"; + + [Header("Enemies")] + public float enemyBaseDamage; + public float enemyBaseLife; + public float enemyBaseRange; + public float enemyBaseAttackSpeed; + + public float damageFlashIntensity; + + [Header("resources")] + public float harvestDuration; + public float harvestAmount; + public float harvestRandomDurationMinimum; + public float harvestRandomDurationMaximum; +} diff --git a/Assets/Scripts/General/GlobalConfigFile.cs.meta b/Assets/Scripts/General/GlobalConfigFile.cs.meta new file mode 100644 index 0000000..3acea83 --- /dev/null +++ b/Assets/Scripts/General/GlobalConfigFile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 32e788fd2a7bdaf4ab145b64231cb833 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/LevelManager/LevelManager.cs b/Assets/Scripts/LevelManager/LevelManager.cs index dc73a2b..fafbd8e 100644 --- a/Assets/Scripts/LevelManager/LevelManager.cs +++ b/Assets/Scripts/LevelManager/LevelManager.cs @@ -96,8 +96,9 @@ public class LevelManager : Singleton #region [Level management] - public void UpdateLevel() + public void AddAndRemoveObjects() { + //add and remove var toAdd = new List(_toAdd); toAdd.ForEach(addedObject => { @@ -113,27 +114,18 @@ public class LevelManager : Singleton _levelObjects.Remove(removedObject); removedObject.LevelDestroy(); }); + } + + public void UpdateLevel() + { + AddAndRemoveObjects(); _levelObjects.ForEach(levelObject => { levelObject.LevelUpdate(); }); - toAdd = new List(_toAdd); - toAdd.ForEach(addedObject => - { - _toAdd.Remove(addedObject); - _levelObjects.Add(addedObject); - addedObject.LevelStart(); - }); - - toRemove = new List(_toRemove); - toRemove.ForEach(removedObject => - { - _toRemove.Remove(removedObject); - _levelObjects.Remove(removedObject); - removedObject.LevelDestroy(); - }); + AddAndRemoveObjects(); } public void ClearLevel() @@ -162,7 +154,9 @@ public class LevelManager : Singleton //create new grid if there is none if (!grid) { + var levelMgrScript = Object.FindObjectOfType(); grid = new GameObject("Grid").AddComponent(); + grid.transform.SetParent(levelMgrScript.transform); } //remove all tilemaps if there is a grid else @@ -199,11 +193,6 @@ public class LevelManager : Singleton ClearLevel(); } - foreach (var ob in Database.Instance.ScriptableObjects) - { - Debug.Log(ob); - } - //fetch level from database _currentLevel = Database.Instance.ScriptableObjects[levelName] as Level; @@ -290,10 +279,5 @@ public class LevelManager : Singleton } - - /// - /// align camera to the rightmost tile of the tilemap - /// - #endregion } \ No newline at end of file