﻿using UnityEngine;
using UnityEngine.UI;

public class InteractionDetails : MonoBehaviour
{
	[SerializeField] private Attackable attackable;
	[SerializeField] private HarvestInfo harvestInfo;
	[SerializeField] private Text text;

	private void Update()
	{
		switch (GameManager.InteractionManager.currentInteraction)
		{
			case InteractionTypes.Reap:
				text.gameObject.SetActive(true);
				text.color = Color.cyan;
				text.text = "+" + harvestInfo.GetValue();
				break;
			case InteractionTypes.Repair:
				float repairCost = harvestInfo.GetBaseValue() * harvestInfo.GetCostMultiplier() * (1 - attackable.GetHealthPercentage());

				if (repairCost <= 0 || Mathf.Approximately(repairCost, 0)) {
					text.gameObject.SetActive(false);
				}
				else {
					text.gameObject.SetActive(true);
					text.color = Color.red;
					text.text = "-" + repairCost;
				}
				break;
			default:
				text.gameObject.SetActive(false);
				break;
		}
	}
}
