creer le scriptable object GlobalConfig
besoin : il serait bien d'avoir un fichier central qui permettrait de modifier toutes les valeurs du jeu sans avoir à aller dans chaque prefab et gosser solution : un fichier central de paramétrage qui sera hooked en middleman dans les valeurs des différents objets du jeu, et pourra être changé en temps réel et appliqué globalement note : le fichier est créé mais les paramètres ne sont pas encore hooked.
This commit is contained in:
parent
3d919455e9
commit
defe6ed4ff
23
Assets/GlobalConfig.asset
Normal file
23
Assets/GlobalConfig.asset
Normal file
@ -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
|
||||
8
Assets/GlobalConfig.asset.meta
Normal file
8
Assets/GlobalConfig.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 132e291fc51a8f445b1183b11a5d6b39
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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}
|
||||
|
||||
8
Assets/Scripts/General/GlobalConfig.cs
Normal file
8
Assets/Scripts/General/GlobalConfig.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GlobalConfig : SingletonBehaviour<GlobalConfig>
|
||||
{
|
||||
[SerializeField]
|
||||
private GlobalConfigFile _current;
|
||||
public GlobalConfigFile Current => _current;
|
||||
}
|
||||
11
Assets/Scripts/General/GlobalConfig.cs.meta
Normal file
11
Assets/Scripts/General/GlobalConfig.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8f878516c4a3324aa1a9672f8b336c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/General/GlobalConfigFile.cs
Normal file
25
Assets/Scripts/General/GlobalConfigFile.cs
Normal file
@ -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;
|
||||
}
|
||||
11
Assets/Scripts/General/GlobalConfigFile.cs.meta
Normal file
11
Assets/Scripts/General/GlobalConfigFile.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32e788fd2a7bdaf4ab145b64231cb833
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -96,8 +96,9 @@ public class LevelManager : Singleton<LevelManager>
|
||||
|
||||
#region [Level management]
|
||||
|
||||
public void UpdateLevel()
|
||||
public void AddAndRemoveObjects()
|
||||
{
|
||||
//add and remove
|
||||
var toAdd = new List<ILevelObject>(_toAdd);
|
||||
toAdd.ForEach(addedObject =>
|
||||
{
|
||||
@ -113,27 +114,18 @@ public class LevelManager : Singleton<LevelManager>
|
||||
_levelObjects.Remove(removedObject);
|
||||
removedObject.LevelDestroy();
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateLevel()
|
||||
{
|
||||
AddAndRemoveObjects();
|
||||
|
||||
_levelObjects.ForEach(levelObject =>
|
||||
{
|
||||
levelObject.LevelUpdate();
|
||||
});
|
||||
|
||||
toAdd = new List<ILevelObject>(_toAdd);
|
||||
toAdd.ForEach(addedObject =>
|
||||
{
|
||||
_toAdd.Remove(addedObject);
|
||||
_levelObjects.Add(addedObject);
|
||||
addedObject.LevelStart();
|
||||
});
|
||||
|
||||
toRemove = new List<ILevelObject>(_toRemove);
|
||||
toRemove.ForEach(removedObject =>
|
||||
{
|
||||
_toRemove.Remove(removedObject);
|
||||
_levelObjects.Remove(removedObject);
|
||||
removedObject.LevelDestroy();
|
||||
});
|
||||
AddAndRemoveObjects();
|
||||
}
|
||||
|
||||
public void ClearLevel()
|
||||
@ -162,7 +154,9 @@ public class LevelManager : Singleton<LevelManager>
|
||||
//create new grid if there is none
|
||||
if (!grid)
|
||||
{
|
||||
var levelMgrScript = Object.FindObjectOfType<LevelManagerScript>();
|
||||
grid = new GameObject("Grid").AddComponent<Grid>();
|
||||
grid.transform.SetParent(levelMgrScript.transform);
|
||||
}
|
||||
//remove all tilemaps if there is a grid
|
||||
else
|
||||
@ -199,11 +193,6 @@ public class LevelManager : Singleton<LevelManager>
|
||||
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<LevelManager>
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// align camera to the rightmost tile of the tilemap
|
||||
/// </summary>
|
||||
|
||||
#endregion
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user