Exemple #1
0
    public void OnPointerDown(PointerEventData eventData)
    {
        //TODO rework this logic, clicking with no resources still blocks one square while it is selected
        //this probably happens because willblockpath is called on the click instead of after place
        if (gridManager.GetNode(coordinates).isWalkable&& !pathfinder.WillBlockPath(coordinates))
        {
            // we want to make a tile nonplaceable if when a defender is placed on it
            bool placementSuccessful = defenderPrefab.SpawnDefender(defenderPrefab, transform.position);

            //if we were unable to place a defender, then we should not block the tile
            if (placementSuccessful)
            {
                gridManager.BlockNodeWalkable(coordinates);
                pathfinder.BroadcastRecalculatePath();
            }
        }
    }