fix unit cost not working anymore
turns out it was an inheritance problem
This commit is contained in:
parent
42fbffd306
commit
27d329df71
@ -5,6 +5,7 @@ public class ObjectPlaceholder : UnitPlaceholder
|
||||
public GameObject Prefab { get; set; }
|
||||
public override void Place()
|
||||
{
|
||||
base.Place();
|
||||
Prefab.Create(transform.position, parent : LevelManager.Instance.LevelTransform);
|
||||
}
|
||||
public override bool CanBePlacedHere()
|
||||
|
||||
@ -8,13 +8,13 @@ public abstract class PlacementButton : MonoBehaviour, IPointerDownHandler
|
||||
{
|
||||
private bool _canUse = false;
|
||||
private Button _button;
|
||||
private DraggablePlaceholder placeholder;
|
||||
private DraggablePlaceholder _placeholder;
|
||||
[SerializeField]
|
||||
private Material _outlineMaterial;
|
||||
|
||||
public bool CanUse => _canUse;
|
||||
public Button Button => _button;
|
||||
public DraggablePlaceholder Placeholder => placeholder;
|
||||
public DraggablePlaceholder Placeholder => _placeholder;
|
||||
public Material OutlineMaterial => _outlineMaterial;
|
||||
protected virtual void Start()
|
||||
{
|
||||
@ -43,7 +43,7 @@ public abstract class PlacementButton : MonoBehaviour, IPointerDownHandler
|
||||
public virtual void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (!_button.interactable) return;
|
||||
placeholder = Place();
|
||||
_placeholder = Place();
|
||||
}
|
||||
protected abstract DraggablePlaceholder Place();
|
||||
protected virtual bool CanPlace()
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TilePlaceholder : DraggablePlaceholder
|
||||
public class TilePlaceholder : UnitPlaceholder
|
||||
{
|
||||
public LevelTile Tile { get; set; }
|
||||
public override void Place()
|
||||
{
|
||||
base.Place();
|
||||
LevelManager.Instance.DynamicTilemap.SetTile(Vector3Int.RoundToInt(transform.position), Tile);
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
using UnityEngine;
|
||||
public abstract class UnitPlaceholder : DraggablePlaceholder
|
||||
{
|
||||
public int Food { get; set; }
|
||||
|
||||
@ -39,8 +39,11 @@ public abstract class UnitPlacementButton : PlacementButton
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerDown(eventData);
|
||||
(Placeholder as UnitPlaceholder).Rock = _rock;
|
||||
(Placeholder as UnitPlaceholder).Wood = _wood;
|
||||
(Placeholder as UnitPlaceholder).Food = _food;
|
||||
if (Placeholder is UnitPlaceholder placeHolder)
|
||||
{
|
||||
placeHolder.Rock = _rock;
|
||||
placeHolder.Wood = _wood;
|
||||
placeHolder.Food = _food;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user