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

namespace MPStudio
{
    [RequireComponent(typeof(ShowBigToSmall))]
    public class ClickScale : MonoBehaviour
    {
        public float animalCost = 0.5f;
        public float startScale = 1.3f;
        
        private ShowBigToSmall showBigToSmall;

        private void Awake()
        {
            showBigToSmall = GetComponent<ShowBigToSmall>();
            showBigToSmall.animalCost = this.animalCost;
            showBigToSmall.startScale = this.startScale;
           
            //没用必须手动禁止
            showBigToSmall.enabled = false;
        }

        // Start is called before the first frame update
        void Start()
        {

        }

        //写这么复杂就是怕连续点有bug，反正我不想停止携程。
        private void OnMouseDown()
        {
            if (showBigToSmall.enabled == true)
            {
                showBigToSmall.enabled = false;
            }
            
            if (showBigToSmall.enabled == false)
            {
                showBigToSmall.enabled = true;
            }
        }

        private void OnMouseUp()
        {
            if (showBigToSmall.enabled == true)
            {
                showBigToSmall.enabled = false;
            }
            
            if (showBigToSmall.enabled == false)
            {
              //什么也不做。；  showBigToSmall.enabled = true;
            }
        }

        /*
        private void OnMouseDown()
        {
            if (showBigToSmall != null)
            {
                Destroy(showBigToSmall);
            }
            
            if (showBigToSmall == null)
            {
                //这里改变参数没有效果
                showBigToSmall= gameObject.AddComponent<ShowBigToSmall>();
                showBigToSmall.animalCost = this.animalCost;
                showBigToSmall.startScale = this.startScale;
                //print("after");
            }
        }

        private void OnMouseUp()
        {
            if (showBigToSmall != null)
            {
                Destroy(showBigToSmall);
            }

            if (showBigToSmall == null)
            {
                //什么也不做。
            }
        }
        */
    }
}