using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class FirstLevelTrigger : MonoBehaviour
{
    //public Transform m_targetTrans;
    //private Vector3 m_pos = new Vector3(0, 5.2f, 0);
    //private Quaternion m_rotation = Quaternion.identity;

    //private void OnTriggerEnter(Collider other)
    //{
    //    if (other.gameObject.CompareTag("Target"))
    //    {
    //        BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget();
    //        BattleCtrl.instance.OnBattleWin();
    //        m_targetTrans.localPosition = m_pos;
    //        m_targetTrans.localRotation = m_rotation;
    //    }
    //}
    //public Transform m_carTrans;
    //public GameObject m_yellowBodyObj;
    //public Transform m_playerTrans;
    //private bool m_bControl = true;
    //private bool m_bControlPass = true;
    //private GameObject m_cubeObj;
    //private void Awake()
    //{
    //    m_cubeObj = m_playerTrans.Find("Cube").gameObject;
    //}

    //private void OnTriggerEnter(Collider other)
    //{
    //    if (other.tag == "Final" && m_bControlPass)
    //    {
    //        m_bControlPass = false;
    //        m_yellowBodyObj.gameObject.SetActive(false);
    //        Invoke("PassLevelAnimation", 3);
    //    }
    //}

    //void PassLevelAnimation()
    //{
    //    m_carTrans.DOLocalMoveZ(9, 2).SetEase(Ease.Linear).OnComplete(() =>
    //    {
    //        BattleCtrl.instance.OnBattleWin();
    //    });
    //}
    //Update is called once per frame
    //void Update()
    //{
    //    if (m_bControl && m_playerTrans.position.y < 5.4f)
    //    {
    //        m_cubeObj.SetActive(false);
    //        m_bControl = false;
    //    }
    //}
    private bool m_bControl = true;
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player" && m_bControl)
        {
            m_bControl = false;
            if(BattleCtrl.instance.levelManager.curLevel.carView.GetLeftBoxNum() > 0)
            {
                BattleCtrl.instance.OnBattleWin();
            }
            else
            {
                BattleCtrl.instance.OnBattleFail();
            }
        }
    }
}
