using System.Collections;
using System.Collections.Generic;
using Game;
using UnityEngine;

namespace InteractiveModules
{

    public class WateringPlant : InteractiveModule
    {
        [SerializeField] private GameScreenAsset nextScreen;
        private bool isDead;
        
        public override void Activate(ScreenController screenController)
        {
            base.Activate(screenController);
            screenController.SetBackgroundColor(ColorType.Green);
        }
        // Start is called before the first frame update
        void Start()
        {
            isDead = false;
        }

        // Update is called once per frame
        void Update()
        {

        }

        public void SwitchScene()
        {
            currentScreenController.LoadScreen(nextScreen);
        }

        public void OnMouseDown()
        {
            if (!isDead)
            {
                isDead = true;
                GameObject plantDead = transform.Find("PlantDead").gameObject;
                Color alpha = new Color(1f, 1f, 1f, 0f);
                plantDead.GetComponent<SpriteRenderer>().color = alpha;
                plantDead.GetComponent<SpriteRenderer>().enabled = true;
                LeanTween.color(plantDead, Color.white, 1f);
                LeanTween.color(gameObject, alpha, 1f);


                Invoke("SwitchScene", 2f);
                currentScreenController.SetBackgroundColor(ColorType.Grey, 1f);
            }
        }
    }
}
