Linked resource management to unit creation
Problem : Les unités et bâtiments ne coutaient rien à construire Solution : J'ai link le système de drag and drop au resource manager. Note : J'ai déshérité le ResourceManager de MonoBehaviour aussi, vu que c'est pas une fonctionalité qui nécessite d'être updaté par frame vraiment, c'est plus du stockage. J'ai testé dans l'éditeur et tout semble fonctionel *fingers crossed*
This commit is contained in:
parent
ede4cbdf5c
commit
43f4c6a39e
@ -11,7 +11,6 @@ GameObject:
|
||||
- component: {fileID: 3028288566889208751}
|
||||
- component: {fileID: 3028288566889208750}
|
||||
- component: {fileID: 3028288566889208749}
|
||||
- component: {fileID: 6046873345209315807}
|
||||
- component: {fileID: -245230096461627285}
|
||||
m_Layer: 0
|
||||
m_Name: LevelManager
|
||||
@ -80,18 +79,6 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: e715669e1ed4b294c82d07ac011e89bb, type: 2}
|
||||
- {fileID: 11400000, guid: a387250a316b97e43be83b85980101e1, type: 2}
|
||||
- {fileID: 11400000, guid: ef5a154519b23a34aaded32e86bf7f2f, type: 2}
|
||||
--- !u!114 &6046873345209315807
|
||||
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: 45e6e814b8c91334ca1d6d0e7f530fef, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &-245230096461627285
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -12,6 +12,7 @@ GameObject:
|
||||
- component: {fileID: 4052934185698417096}
|
||||
- component: {fileID: 4052934185698417099}
|
||||
- component: {fileID: 4052934185698417098}
|
||||
- component: {fileID: 2108251457}
|
||||
m_Layer: 5
|
||||
m_Name: img_card
|
||||
m_TagString: Untagged
|
||||
@ -31,8 +32,8 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4052934186652138536}
|
||||
m_RootOrder: 2
|
||||
m_Father: {fileID: 4052934185976516874}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@ -121,6 +122,18 @@ MonoBehaviour:
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!225 &2108251457
|
||||
CanvasGroup:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4052934185698417100}
|
||||
m_Enabled: 1
|
||||
m_Alpha: 1
|
||||
m_Interactable: 0
|
||||
m_BlocksRaycasts: 0
|
||||
m_IgnoreParentGroups: 0
|
||||
--- !u!1 &4052934185976516877
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -151,7 +164,10 @@ RectTransform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Children:
|
||||
- {fileID: 4052934186809116250}
|
||||
- {fileID: 4052934185698417101}
|
||||
- {fileID: 4052934186824254731}
|
||||
m_Father: {fileID: 4052934186652138536}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -251,6 +267,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4052934186652138536}
|
||||
- component: {fileID: 8584020651799379602}
|
||||
m_Layer: 5
|
||||
m_Name: BuyableUnitItem
|
||||
m_TagString: Untagged
|
||||
@ -271,17 +288,28 @@ RectTransform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 4052934185976516874}
|
||||
- {fileID: 4052934186809116250}
|
||||
- {fileID: 4052934185698417101}
|
||||
- {fileID: 4052934186824254731}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &8584020651799379602
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4052934186652138539}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 1
|
||||
m_VerticalFit: 1
|
||||
--- !u!1 &4052934186809116253
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -293,7 +321,7 @@ GameObject:
|
||||
- component: {fileID: 4052934186809116250}
|
||||
- component: {fileID: 4052934186809116249}
|
||||
- component: {fileID: 4052934186809116248}
|
||||
- component: {fileID: 4052934186809116251}
|
||||
- component: {fileID: 2108251458}
|
||||
m_Layer: 5
|
||||
m_Name: img_cardBack
|
||||
m_TagString: Untagged
|
||||
@ -313,8 +341,8 @@ RectTransform:
|
||||
m_LocalScale: {x: 1.0796, y: 1.0796, z: 1.0796}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4052934186652138536}
|
||||
m_RootOrder: 1
|
||||
m_Father: {fileID: 4052934185976516874}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@ -359,50 +387,18 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &4052934186809116251
|
||||
MonoBehaviour:
|
||||
--- !u!225 &2108251458
|
||||
CanvasGroup:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4052934186809116253}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.5242524, g: 0.9339623, b: 0.81106573, a: 1}
|
||||
m_PressedColor: {r: 0.41930506, g: 0.8018868, b: 0.2988163, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 4052934186809116248}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Alpha: 1
|
||||
m_Interactable: 0
|
||||
m_BlocksRaycasts: 0
|
||||
m_IgnoreParentGroups: 0
|
||||
--- !u!1 &4052934186824254730
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -414,6 +410,7 @@ GameObject:
|
||||
- component: {fileID: 4052934186824254731}
|
||||
- component: {fileID: 4052934186824254729}
|
||||
- component: {fileID: 4052934186824254728}
|
||||
- component: {fileID: 2108251456}
|
||||
m_Layer: 5
|
||||
m_Name: txt_cost
|
||||
m_TagString: Untagged
|
||||
@ -428,13 +425,13 @@ RectTransform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4052934186824254730}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4052934186652138536}
|
||||
m_RootOrder: 3
|
||||
m_Father: {fileID: 4052934185976516874}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@ -538,3 +535,15 @@ MonoBehaviour:
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!225 &2108251456
|
||||
CanvasGroup:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4052934186824254730}
|
||||
m_Enabled: 1
|
||||
m_Alpha: 1
|
||||
m_Interactable: 0
|
||||
m_BlocksRaycasts: 0
|
||||
m_IgnoreParentGroups: 0
|
||||
|
||||
1254
Assets/Prefabs/UI/BuyableUnitsView/GameObjectPlacementButton.prefab
Normal file
1254
Assets/Prefabs/UI/BuyableUnitsView/GameObjectPlacementButton.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e20680474d73eee49836ff9cbc6d0b28
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1254
Assets/Prefabs/UI/BuyableUnitsView/TilePlacementButton.prefab
Normal file
1254
Assets/Prefabs/UI/BuyableUnitsView/TilePlacementButton.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afc444040d3adcf45a882e4882521f5e
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/Prefabs/UI/BuyableUnitsView/UIButtonOutline.mat
Normal file
60
Assets/Prefabs/UI/BuyableUnitsView/UIButtonOutline.mat
Normal file
@ -0,0 +1,60 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UIButtonOutline
|
||||
m_Shader: {fileID: -6465566751694194690, guid: 5aed7d9426a25544b928536f1bd9edc0, type: 3}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AlphaTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MaskTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _EnableExternalAlpha: 0
|
||||
- _OutlineThickness: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Flip: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c14409fbe59d3a947a21aab7ffa6f6d0
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,14 @@
|
||||
using Codice.CM.Client.Differences;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class DraggablePlaceholder : MonoBehaviour
|
||||
{
|
||||
public int Food { get; set; }
|
||||
public int Rock { get; set; }
|
||||
public int Wood { get; set; }
|
||||
|
||||
protected const string OutlineColor = "_OutlineColor";
|
||||
|
||||
[SerializeField]
|
||||
@ -13,7 +18,7 @@ public abstract class DraggablePlaceholder : MonoBehaviour
|
||||
|
||||
protected Camera _mainCamCache;
|
||||
protected Rect _lvlBoundsCache;
|
||||
protected bool _isOnValidPosition;
|
||||
protected bool _canBePlacedHere;
|
||||
|
||||
private List<SpriteRenderer> _outlineRenderers = new List<SpriteRenderer>();
|
||||
public List<SpriteRenderer> OutlineRenderers
|
||||
@ -41,8 +46,9 @@ public abstract class DraggablePlaceholder : MonoBehaviour
|
||||
{
|
||||
if (!Input.GetMouseButton(0))
|
||||
{
|
||||
if (_isOnValidPosition)
|
||||
if (_canBePlacedHere)
|
||||
{
|
||||
ResourceManager.Instance.Remove(Rock, Wood, Food);
|
||||
Place();
|
||||
}
|
||||
Destroy(gameObject);
|
||||
@ -50,7 +56,7 @@ public abstract class DraggablePlaceholder : MonoBehaviour
|
||||
|
||||
UpdatePosition();
|
||||
|
||||
_isOnValidPosition = CanBePlacedHere();
|
||||
_canBePlacedHere = CanBePlacedHere();
|
||||
ShowValidity();
|
||||
}
|
||||
|
||||
@ -74,7 +80,8 @@ public abstract class DraggablePlaceholder : MonoBehaviour
|
||||
/// </summary>
|
||||
public virtual bool CanBePlacedHere()
|
||||
{
|
||||
return !LevelManager.Instance.Has<ILevelObject>(obj => obj.Position.IsContainedIn(transform.position));
|
||||
return !LevelManager.Instance.Has<ILevelObject>(obj => obj.Position.IsContainedIn(transform.position))
|
||||
&& ResourceManager.Instance.EnoughFor(Rock, Wood, Food);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -85,7 +92,7 @@ public abstract class DraggablePlaceholder : MonoBehaviour
|
||||
/// <returns></returns>
|
||||
public virtual void ShowValidity()
|
||||
{
|
||||
Color getColor() => _isOnValidPosition ? _validColor : _invalidColor;
|
||||
Color getColor() => _canBePlacedHere ? _validColor : _invalidColor;
|
||||
|
||||
foreach (var child in _outlineRenderers)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@ public class GameObjectPlacementButton : UnitPlacementButton
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _prefab;
|
||||
protected override void Place()
|
||||
protected override DraggablePlaceholder Place()
|
||||
{
|
||||
var instance = Instantiate(_prefab);
|
||||
|
||||
@ -20,6 +20,7 @@ public class GameObjectPlacementButton : UnitPlacementButton
|
||||
foreach (var script in instance.transform.GetAllComponents<MonoBehaviour>()) Destroy(script);
|
||||
|
||||
var placeholder = instance.AddComponent<ObjectPlaceholder>();
|
||||
|
||||
placeholder.Prefab = _prefab;
|
||||
|
||||
//assign outline material to all renderers of the placeholder
|
||||
@ -34,9 +35,9 @@ public class GameObjectPlacementButton : UnitPlacementButton
|
||||
placeholder.OutlineRenderers.Add(rend);
|
||||
}
|
||||
|
||||
|
||||
|
||||
CreateRange(placeholder, detectionRect);
|
||||
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
void CreateRange(DraggablePlaceholder placeholder, Rect detectionRect)
|
||||
|
||||
@ -5,7 +5,7 @@ using UnityEngine;
|
||||
public class TilePlacementButton : UnitPlacementButton
|
||||
{
|
||||
public LevelTile tile;
|
||||
protected override void Place()
|
||||
protected override DraggablePlaceholder Place()
|
||||
{
|
||||
var instance = new GameObject(tile.name);
|
||||
var placeholder = instance.AddComponent<TilePlaceholder>();
|
||||
@ -15,5 +15,6 @@ public class TilePlacementButton : UnitPlacementButton
|
||||
rend.sortingLayerName = "Character";
|
||||
rend.material = _outlineMaterial;
|
||||
rend.sortingOrder = 2;
|
||||
return placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(Button))]
|
||||
public abstract class UnitPlacementButton : MonoBehaviour, IPointerDownHandler
|
||||
{
|
||||
[SerializeField]
|
||||
protected Material _outlineMaterial;
|
||||
[SerializeField]
|
||||
protected Sprite _detectionRangeSprite;
|
||||
|
||||
[SerializeField]
|
||||
private int _wood;
|
||||
[SerializeField]
|
||||
private int _rock;
|
||||
[SerializeField]
|
||||
private int _food;
|
||||
|
||||
private Button _button;
|
||||
[SerializeField]
|
||||
private TMP_Text _foodLabel;
|
||||
[SerializeField]
|
||||
private TMP_Text _woodLabel;
|
||||
[SerializeField]
|
||||
private TMP_Text _rockLabel;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
_button = GetComponent<Button>();
|
||||
}
|
||||
protected virtual void Update()
|
||||
{
|
||||
_button.interactable = ResourceManager.Instance.EnoughFor(_rock, _wood, _food);
|
||||
SetTextFor(_foodLabel, _food);
|
||||
SetTextFor(_rockLabel, _rock);
|
||||
SetTextFor(_woodLabel, _wood);
|
||||
}
|
||||
void SetTextFor(TMP_Text label, int value)
|
||||
{
|
||||
label.transform.parent.gameObject.SetActive(value > 0);
|
||||
label.text = "" + value;
|
||||
}
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
Place();
|
||||
if (!_button.interactable) return;
|
||||
var placeholder = Place();
|
||||
placeholder.Rock = _rock;
|
||||
placeholder.Wood = _wood;
|
||||
placeholder.Food = _food;
|
||||
}
|
||||
protected abstract void Place();
|
||||
protected abstract DraggablePlaceholder Place();
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ using UnityEngine;
|
||||
/// <summary>
|
||||
/// Sert d'inventaire et gère l'accès aux ressources
|
||||
/// </summary>
|
||||
public class ResourceManager : MonoBehaviour
|
||||
public class ResourceManager : Singleton<ResourceManager>
|
||||
{
|
||||
private static ResourceManager _instance = null;
|
||||
private int _rockAmount = 20;
|
||||
@ -13,27 +13,6 @@ public class ResourceManager : MonoBehaviour
|
||||
private const int MAX = 100;
|
||||
private const int MIN = 0;
|
||||
|
||||
public ResourceManager() { }
|
||||
public static ResourceManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_instance != null && _instance != this)
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
public int RockAmount
|
||||
{
|
||||
set
|
||||
|
||||
@ -59,6 +59,9 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "7aa529fabe2b4b199495cc44e889cc4b"
|
||||
},
|
||||
{
|
||||
"m_Id": "b11ac65f24a34a4b89384329efe707dc"
|
||||
}
|
||||
],
|
||||
"m_GroupDatas": [],
|
||||
@ -92,6 +95,20 @@
|
||||
"m_SlotId": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "03db1e07f0ee40d5bbb14b9afba574cc"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b11ac65f24a34a4b89384329efe707dc"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
@ -204,6 +221,20 @@
|
||||
"m_SlotId": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "9a7d1b885a4e4686adebd71427853c28"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b11ac65f24a34a4b89384329efe707dc"
|
||||
},
|
||||
"m_SlotId": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
@ -487,6 +518,30 @@
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
|
||||
"m_ObjectId": "1e5d0b6e4ea849c1af623505437e3d55",
|
||||
"m_Id": 2,
|
||||
"m_DisplayName": "Out",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot",
|
||||
@ -887,10 +942,10 @@
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": 1697.5999755859375,
|
||||
"y": -127.99999237060547,
|
||||
"x": 1680.800048828125,
|
||||
"y": -154.39999389648438,
|
||||
"width": 208.0,
|
||||
"height": 301.60003662109377
|
||||
"height": 301.5999755859375
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
@ -1017,6 +1072,30 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
|
||||
"m_ObjectId": "8992789161914a099c54c3eb46f3f39c",
|
||||
"m_Id": 1,
|
||||
"m_DisplayName": "B",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "B",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 1.0,
|
||||
"y": 1.0,
|
||||
"z": 1.0,
|
||||
"w": 1.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Texture2DPropertiesNode",
|
||||
@ -1156,6 +1235,49 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.SubtractNode",
|
||||
"m_ObjectId": "b11ac65f24a34a4b89384329efe707dc",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "Subtract",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": 1680.800048828125,
|
||||
"y": -477.6000061035156,
|
||||
"width": 208.0,
|
||||
"height": 301.5999755859375
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "c61e864a2bb9473399f2da113e515de3"
|
||||
},
|
||||
{
|
||||
"m_Id": "8992789161914a099c54c3eb46f3f39c"
|
||||
},
|
||||
{
|
||||
"m_Id": "1e5d0b6e4ea849c1af623505437e3d55"
|
||||
}
|
||||
],
|
||||
"synonyms": [
|
||||
"subtraction",
|
||||
"remove",
|
||||
"minus",
|
||||
"take away"
|
||||
],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": true,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
|
||||
@ -1255,6 +1377,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
|
||||
"m_ObjectId": "c61e864a2bb9473399f2da113e515de3",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "A",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "A",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 1.0,
|
||||
"y": 1.0,
|
||||
"z": 1.0,
|
||||
"w": 1.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
|
||||
@ -14,6 +14,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
_sprite: {fileID: 21300000, guid: ccca3e050cb082b45af0a099790463f6, type: 3}
|
||||
_isCollidable: 0
|
||||
_yieldPrefab: {fileID: 0}
|
||||
_yieldSpeed: 0
|
||||
_randomPositionConfig: 0.5
|
||||
_yieldPrefab: {fileID: 6962989255644195630, guid: a2dc5d9672c10074fa9c35c12f6339c1, type: 3}
|
||||
_yieldSpeed: 0.1
|
||||
_randomPositionConfig: 0.25
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user