extraire les prix et cooldowns des unit cards
problème : le fait que les prix et les cooldowns étaient dans les game objects directement rendait le design compliqué solution : créer un scriptable object pour contenir l'info des unit cards
This commit is contained in:
parent
fd2e2e3991
commit
927c08559f
8
Assets/Design/UnitCards.meta
Normal file
8
Assets/Design/UnitCards.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 160cacddb5bd0764ebef981b91f59608
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/Archer.asset
Normal file
18
Assets/Design/UnitCards/Archer.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/Archer.asset.meta
Normal file
8
Assets/Design/UnitCards/Archer.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9ff4b606166b07d4bb3afb15e5a23f41
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/Castle.asset
Normal file
18
Assets/Design/UnitCards/Castle.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/Castle.asset.meta
Normal file
8
Assets/Design/UnitCards/Castle.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4728bef0a18b70945bedf5b1190c491e
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/Farm.asset
Normal file
18
Assets/Design/UnitCards/Farm.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/Farm.asset.meta
Normal file
8
Assets/Design/UnitCards/Farm.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f4dcf11b827a5ca49a70b5db1e72e16e
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/Farmer.asset
Normal file
18
Assets/Design/UnitCards/Farmer.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/Farmer.asset.meta
Normal file
8
Assets/Design/UnitCards/Farmer.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ee85fc25d3460c745806649e7f9d166a
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/FarmerMob.asset
Normal file
18
Assets/Design/UnitCards/FarmerMob.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/FarmerMob.asset.meta
Normal file
8
Assets/Design/UnitCards/FarmerMob.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f433c214b267f2a40b7427ae18ac80ac
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/House.asset
Normal file
18
Assets/Design/UnitCards/House.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/House.asset.meta
Normal file
8
Assets/Design/UnitCards/House.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4fda8972f6f46684891773953155782e
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/Knight.asset
Normal file
18
Assets/Design/UnitCards/Knight.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/Knight.asset.meta
Normal file
8
Assets/Design/UnitCards/Knight.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0334115ab72f6d5449497db1bb50377e
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Design/UnitCards/Mill.asset
Normal file
18
Assets/Design/UnitCards/Mill.asset
Normal file
@ -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
|
||||||
8
Assets/Design/UnitCards/Mill.asset.meta
Normal file
8
Assets/Design/UnitCards/Mill.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b326df01bdba895448b1df3f2918fa9b
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -2428,6 +2428,10 @@ PrefabInstance:
|
|||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 1092900232}
|
m_TransformParent: {fileID: 1092900232}
|
||||||
m_Modifications:
|
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}
|
- target: {fileID: 400568530076150058, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 0
|
value: 0
|
||||||
@ -2478,11 +2482,11 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
@ -2490,7 +2494,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
- target: {fileID: 907652128862280229, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -103.3
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1144883118211503064, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
- target: {fileID: 1144883118211503064, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
@ -2684,6 +2688,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 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}
|
- target: {fileID: 3964878483247902818, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 0
|
value: 0
|
||||||
@ -2700,6 +2708,22 @@ PrefabInstance:
|
|||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 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}
|
- target: {fileID: 4453469705328566160, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 0
|
value: 0
|
||||||
@ -2964,6 +2988,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 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}
|
- target: {fileID: 7106892479276285262, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 0
|
value: 0
|
||||||
@ -3012,6 +3040,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 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}
|
- target: {fileID: 8992921944992653498, guid: 306211cf6348ac747a78d89bd72fca3e, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 0
|
value: 0
|
||||||
|
|||||||
@ -11,7 +11,7 @@ public class GameObjectPlacementButton : UnitPlacementButton
|
|||||||
var isBuilding = _prefab.GetComponent<Building>();
|
var isBuilding = _prefab.GetComponent<Building>();
|
||||||
var defaultPopCost = GlobalConfig.Instance.Current.populationCostPerUnit;
|
var defaultPopCost = GlobalConfig.Instance.Current.populationCostPerUnit;
|
||||||
var hasEnoughPopulation = isBuilding || ResourceManager.Instance.EnoughPopulationFor(defaultPopCost);
|
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
|
&& hasEnoughPopulation
|
||||||
&& base.CanPlace();
|
&& base.CanPlace();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ public class TilePlacementButton : UnitPlacementButton
|
|||||||
|
|
||||||
protected override bool CanPlace()
|
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()
|
protected override DraggablePlaceholder Place()
|
||||||
|
|||||||
19
Assets/Scripts/Drag&Drop/UnitCard.cs
Normal file
19
Assets/Scripts/Drag&Drop/UnitCard.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
11
Assets/Scripts/Drag&Drop/UnitCard.cs.meta
Normal file
11
Assets/Scripts/Drag&Drop/UnitCard.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a92d696df7037b44585aaac56ec9ed98
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -11,14 +11,8 @@ public abstract class UnitPlacementButton : PlacementButton
|
|||||||
protected Sprite _detectionRangeSprite;
|
protected Sprite _detectionRangeSprite;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
protected int _wood;
|
protected UnitCard _unitCardInformation;
|
||||||
[SerializeField]
|
|
||||||
protected int _rock;
|
|
||||||
[SerializeField]
|
|
||||||
protected int _food;
|
|
||||||
[SerializeField]
|
|
||||||
protected int _cooldownInSeconds = 3;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private TMP_Text _foodLabel;
|
private TMP_Text _foodLabel;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
@ -34,9 +28,9 @@ public abstract class UnitPlacementButton : PlacementButton
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
SetTextFor(_foodLabel, _food);
|
SetTextFor(_foodLabel, _unitCardInformation.Food);
|
||||||
SetTextFor(_rockLabel, _rock);
|
SetTextFor(_rockLabel, _unitCardInformation.Rock);
|
||||||
SetTextFor(_woodLabel, _wood);
|
SetTextFor(_woodLabel, _unitCardInformation.Wood);
|
||||||
}
|
}
|
||||||
void SetTextFor(TMP_Text label, int value)
|
void SetTextFor(TMP_Text label, int value)
|
||||||
{
|
{
|
||||||
@ -48,9 +42,9 @@ public abstract class UnitPlacementButton : PlacementButton
|
|||||||
base.OnPointerDown(eventData);
|
base.OnPointerDown(eventData);
|
||||||
if (Placeholder is UnitPlaceholder placeHolder)
|
if (Placeholder is UnitPlaceholder placeHolder)
|
||||||
{
|
{
|
||||||
placeHolder.Rock = _rock;
|
placeHolder.Rock = _unitCardInformation.Rock;
|
||||||
placeHolder.Wood = _wood;
|
placeHolder.Wood = _unitCardInformation.Wood;
|
||||||
placeHolder.Food = _food;
|
placeHolder.Food = _unitCardInformation.Food;
|
||||||
placeHolder.WasPlaced += HandleCooldown;
|
placeHolder.WasPlaced += HandleCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,10 +61,10 @@ public abstract class UnitPlacementButton : PlacementButton
|
|||||||
var countDown = 0f;
|
var countDown = 0f;
|
||||||
_lockedByCooldown = true;
|
_lockedByCooldown = true;
|
||||||
_cooldownIndicator.gameObject.SetActive(true);
|
_cooldownIndicator.gameObject.SetActive(true);
|
||||||
while (countDown < _cooldownInSeconds)
|
while (countDown < _unitCardInformation.CooldownInSeconds)
|
||||||
{
|
{
|
||||||
countDown += Time.deltaTime;
|
countDown += Time.deltaTime;
|
||||||
var percentDone = countDown / _cooldownInSeconds;
|
var percentDone = countDown / _unitCardInformation.CooldownInSeconds;
|
||||||
_cooldownIndicator.fillAmount = 1 - percentDone;
|
_cooldownIndicator.fillAmount = 1 - percentDone;
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user