gather-and-defend/Assets/Scripts/Drag&Drop/ObjectPlaceholder.cs
Felix Boucher b54627196c population mechanic with art
- added art for house and UI
- put population in ResourceManager
- create house prefab
- added code for adding and removing pop depending on entity
- refactor harvesters so they inherit from ally
- modify placeholders and buttons so that only units cost population
- add events for population and resources changing
- add population relative configs to global config
- add start resources values to Levels
- add debug feature for generating resources for free
2023-10-29 19:12:32 -04:00

19 lines
733 B
C#

using UnityEngine;
public class ObjectPlaceholder : DraggablePlaceholder
{
public GameObject Prefab { get; set; }
public override void Place()
{
Prefab.Create(transform.position, parent : LevelManager.Instance.LevelTransform);
}
public override bool CanBePlacedHere()
{
var objsOnPosition = LevelManager.Instance.GetAll<ILevelObject>(obj => obj.Position.IsContainedIn(transform.position));
var positionIsCollidable = objsOnPosition.Exists(obj => obj.IsCollidable);
return !positionIsCollidable
&& _lvlBoundsCache.Contains(transform.position)
&& ResourceManager.Instance.EnoughFor(Rock, Wood, Food, Prefab.GetComponent<Building>() ? 0 : 1);
}
}