gather-and-defend/Assets/Scripts/Drag&Drop/MaximumPopulationReachedCardAlert.cs
craftwill cf1df05d6d Added warning on house card to let player know to build one (#5)
Reviewed-on: #5
Reviewed-by: Ader_Alisma <ader.alisma.1@ens.etsmtl.ca>
Co-authored-by: craftwill <william-gin1@hotmail.com>
Co-committed-by: craftwill <william-gin1@hotmail.com>
2025-04-29 18:59:31 +00:00

29 lines
791 B
C#

using GatherAndDefend.Events;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MaximumPopulationReachedCardAlert : MonoBehaviour
{
[SerializeField] private Animator _warningAnimator;
private void Start()
{
EventAggregator.Instance.GetEvent<PopulationChangedEvent>().Attach(HandlePopulationChangedEvent);
}
private void HandlePopulationChangedEvent(PopulationChangedEventArgs args)
{
if (args.Pop / args.MaxPop >= GlobalConfig.Instance.Current.populationWarningPercentage)
{
// Show warning
_warningAnimator.SetBool("isWarning", true);
}
else
{
// Hide warning
_warningAnimator.SetBool("isWarning", false);
}
}
}