diff --git a/Assets/Design/UnitCards.meta b/Assets/Design/UnitCards.meta new file mode 100644 index 0000000..b1fd5d8 --- /dev/null +++ b/Assets/Design/UnitCards.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 160cacddb5bd0764ebef981b91f59608 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/Archer.asset b/Assets/Design/UnitCards/Archer.asset new file mode 100644 index 0000000..32e6670 --- /dev/null +++ b/Assets/Design/UnitCards/Archer.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: Archer + m_EditorClassIdentifier: + _wood: 30 + _rock: 0 + _food: 20 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/Archer.asset.meta b/Assets/Design/UnitCards/Archer.asset.meta new file mode 100644 index 0000000..78c1a74 --- /dev/null +++ b/Assets/Design/UnitCards/Archer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ff4b606166b07d4bb3afb15e5a23f41 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/Castle.asset b/Assets/Design/UnitCards/Castle.asset new file mode 100644 index 0000000..9967f38 --- /dev/null +++ b/Assets/Design/UnitCards/Castle.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: Castle + m_EditorClassIdentifier: + _wood: 0 + _rock: 350 + _food: 0 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/Castle.asset.meta b/Assets/Design/UnitCards/Castle.asset.meta new file mode 100644 index 0000000..70a7235 --- /dev/null +++ b/Assets/Design/UnitCards/Castle.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4728bef0a18b70945bedf5b1190c491e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/Farm.asset b/Assets/Design/UnitCards/Farm.asset new file mode 100644 index 0000000..441d687 --- /dev/null +++ b/Assets/Design/UnitCards/Farm.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: Farm + m_EditorClassIdentifier: + _wood: 40 + _rock: 0 + _food: 0 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/Farm.asset.meta b/Assets/Design/UnitCards/Farm.asset.meta new file mode 100644 index 0000000..5ac8b5d --- /dev/null +++ b/Assets/Design/UnitCards/Farm.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f4dcf11b827a5ca49a70b5db1e72e16e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/Farmer.asset b/Assets/Design/UnitCards/Farmer.asset new file mode 100644 index 0000000..c73acb3 --- /dev/null +++ b/Assets/Design/UnitCards/Farmer.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: Farmer + m_EditorClassIdentifier: + _wood: 0 + _rock: 0 + _food: 10 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/Farmer.asset.meta b/Assets/Design/UnitCards/Farmer.asset.meta new file mode 100644 index 0000000..8bfd9b2 --- /dev/null +++ b/Assets/Design/UnitCards/Farmer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ee85fc25d3460c745806649e7f9d166a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/FarmerMob.asset b/Assets/Design/UnitCards/FarmerMob.asset new file mode 100644 index 0000000..c48ae84 --- /dev/null +++ b/Assets/Design/UnitCards/FarmerMob.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: FarmerMob + m_EditorClassIdentifier: + _wood: 0 + _rock: 0 + _food: 10 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/FarmerMob.asset.meta b/Assets/Design/UnitCards/FarmerMob.asset.meta new file mode 100644 index 0000000..bed19bf --- /dev/null +++ b/Assets/Design/UnitCards/FarmerMob.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f433c214b267f2a40b7427ae18ac80ac +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/House.asset b/Assets/Design/UnitCards/House.asset new file mode 100644 index 0000000..007b591 --- /dev/null +++ b/Assets/Design/UnitCards/House.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: House + m_EditorClassIdentifier: + _wood: 50 + _rock: 0 + _food: 0 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/House.asset.meta b/Assets/Design/UnitCards/House.asset.meta new file mode 100644 index 0000000..9cdb88d --- /dev/null +++ b/Assets/Design/UnitCards/House.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fda8972f6f46684891773953155782e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/Knight.asset b/Assets/Design/UnitCards/Knight.asset new file mode 100644 index 0000000..7152766 --- /dev/null +++ b/Assets/Design/UnitCards/Knight.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: Knight + m_EditorClassIdentifier: + _wood: 0 + _rock: 0 + _food: 60 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/Knight.asset.meta b/Assets/Design/UnitCards/Knight.asset.meta new file mode 100644 index 0000000..c62646e --- /dev/null +++ b/Assets/Design/UnitCards/Knight.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0334115ab72f6d5449497db1bb50377e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Design/UnitCards/Mill.asset b/Assets/Design/UnitCards/Mill.asset new file mode 100644 index 0000000..fed8a05 --- /dev/null +++ b/Assets/Design/UnitCards/Mill.asset @@ -0,0 +1,18 @@ +%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: a92d696df7037b44585aaac56ec9ed98, type: 3} + m_Name: Mill + m_EditorClassIdentifier: + _wood: 120 + _rock: 0 + _food: 0 + _cooldownInSeconds: 3 diff --git a/Assets/Design/UnitCards/Mill.asset.meta b/Assets/Design/UnitCards/Mill.asset.meta new file mode 100644 index 0000000..ef7241d --- /dev/null +++ b/Assets/Design/UnitCards/Mill.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b326df01bdba895448b1df3f2918fa9b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 539f6c9..c212a19 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -2428,6 +2428,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1092900232} m_Modifications: + - target: {fileID: 385500479923064057, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: f433c214b267f2a40b7427ae18ac80ac, type: 2} - target: {fileID: 400568530076150058, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -2478,11 +2482,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchoredPosition.x @@ -2490,7 +2494,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchoredPosition.y - value: -103.3 + value: 0 objectReference: {fileID: 0} - target: {fileID: 1144883118211503064, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y @@ -2684,6 +2688,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 3060107528281312343, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: b326df01bdba895448b1df3f2918fa9b, type: 2} - target: {fileID: 3964878483247902818, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -2700,6 +2708,22 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 4021885618240460209, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: 9ff4b606166b07d4bb3afb15e5a23f41, type: 2} + - target: {fileID: 4021885618914922922, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: ee85fc25d3460c745806649e7f9d166a, type: 2} + - target: {fileID: 4021885619120025647, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: 4728bef0a18b70945bedf5b1190c491e, type: 2} + - target: {fileID: 4448694950779727683, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: 0334115ab72f6d5449497db1bb50377e, type: 2} - target: {fileID: 4453469705328566160, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -2964,6 +2988,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 6772290102801599907, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: f4dcf11b827a5ca49a70b5db1e72e16e, type: 2} - target: {fileID: 7106892479276285262, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -3012,6 +3040,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 8434244524890535526, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} + propertyPath: _unitCardInformation + value: + objectReference: {fileID: 11400000, guid: 4fda8972f6f46684891773953155782e, type: 2} - target: {fileID: 8992921944992653498, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3} propertyPath: m_AnchorMax.y value: 0 diff --git a/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs b/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs index 375f28f..2bbccb7 100644 --- a/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs +++ b/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs @@ -11,7 +11,7 @@ public class GameObjectPlacementButton : UnitPlacementButton var isBuilding = _prefab.GetComponent(); var defaultPopCost = GlobalConfig.Instance.Current.populationCostPerUnit; var hasEnoughPopulation = isBuilding || ResourceManager.Instance.EnoughPopulationFor(defaultPopCost); - return ResourceManager.Instance.EnoughFor(_rock, _wood, _food) + return ResourceManager.Instance.EnoughFor(_unitCardInformation.Rock, _unitCardInformation.Wood, _unitCardInformation.Food) && hasEnoughPopulation && base.CanPlace(); } diff --git a/Assets/Scripts/Drag&Drop/TilePlacementButton.cs b/Assets/Scripts/Drag&Drop/TilePlacementButton.cs index 4feb5b0..3390f49 100644 --- a/Assets/Scripts/Drag&Drop/TilePlacementButton.cs +++ b/Assets/Scripts/Drag&Drop/TilePlacementButton.cs @@ -8,7 +8,7 @@ public class TilePlacementButton : UnitPlacementButton protected override bool CanPlace() { - return ResourceManager.Instance.EnoughFor(_rock, _wood, _food) && base.CanPlace(); + return ResourceManager.Instance.EnoughFor(_unitCardInformation.Rock, _unitCardInformation.Wood, _unitCardInformation.Food) && base.CanPlace(); } protected override DraggablePlaceholder Place() diff --git a/Assets/Scripts/Drag&Drop/UnitCard.cs b/Assets/Scripts/Drag&Drop/UnitCard.cs new file mode 100644 index 0000000..81a2eda --- /dev/null +++ b/Assets/Scripts/Drag&Drop/UnitCard.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +[CreateAssetMenu(menuName = "Gather And Defend/Buyable Unit Card")] +public class UnitCard : ScriptableObject +{ + [SerializeField] + protected int _wood; + [SerializeField] + protected int _rock; + [SerializeField] + protected int _food; + [SerializeField] + protected int _cooldownInSeconds = 3; + + public int Wood => _wood; + public int Rock => _rock; + public int Food => _food; + public int CooldownInSeconds => _cooldownInSeconds; +} \ No newline at end of file diff --git a/Assets/Scripts/Drag&Drop/UnitCard.cs.meta b/Assets/Scripts/Drag&Drop/UnitCard.cs.meta new file mode 100644 index 0000000..ecb6300 --- /dev/null +++ b/Assets/Scripts/Drag&Drop/UnitCard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a92d696df7037b44585aaac56ec9ed98 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Drag&Drop/UnitPlacementButton.cs b/Assets/Scripts/Drag&Drop/UnitPlacementButton.cs index 6339fb1..95639bb 100644 --- a/Assets/Scripts/Drag&Drop/UnitPlacementButton.cs +++ b/Assets/Scripts/Drag&Drop/UnitPlacementButton.cs @@ -11,14 +11,8 @@ public abstract class UnitPlacementButton : PlacementButton protected Sprite _detectionRangeSprite; [SerializeField] - protected int _wood; - [SerializeField] - protected int _rock; - [SerializeField] - protected int _food; - [SerializeField] - protected int _cooldownInSeconds = 3; - + protected UnitCard _unitCardInformation; + [SerializeField] private TMP_Text _foodLabel; [SerializeField] @@ -34,9 +28,9 @@ public abstract class UnitPlacementButton : PlacementButton { base.Update(); - SetTextFor(_foodLabel, _food); - SetTextFor(_rockLabel, _rock); - SetTextFor(_woodLabel, _wood); + SetTextFor(_foodLabel, _unitCardInformation.Food); + SetTextFor(_rockLabel, _unitCardInformation.Rock); + SetTextFor(_woodLabel, _unitCardInformation.Wood); } void SetTextFor(TMP_Text label, int value) { @@ -48,9 +42,9 @@ public abstract class UnitPlacementButton : PlacementButton base.OnPointerDown(eventData); if (Placeholder is UnitPlaceholder placeHolder) { - placeHolder.Rock = _rock; - placeHolder.Wood = _wood; - placeHolder.Food = _food; + placeHolder.Rock = _unitCardInformation.Rock; + placeHolder.Wood = _unitCardInformation.Wood; + placeHolder.Food = _unitCardInformation.Food; placeHolder.WasPlaced += HandleCooldown; } @@ -67,10 +61,10 @@ public abstract class UnitPlacementButton : PlacementButton var countDown = 0f; _lockedByCooldown = true; _cooldownIndicator.gameObject.SetActive(true); - while (countDown < _cooldownInSeconds) + while (countDown < _unitCardInformation.CooldownInSeconds) { countDown += Time.deltaTime; - var percentDone = countDown / _cooldownInSeconds; + var percentDone = countDown / _unitCardInformation.CooldownInSeconds; _cooldownIndicator.fillAmount = 1 - percentDone; yield return null; }